2014년 7월 17일 목요일

[JavaScript] KakaoTalk App share url (카톡 url 공유)



<!doctype HTML> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>KakaoLink Demo(Web Button) - Kakao Javascript SDK</title> <script src="https://developers.kakao.com/sdk/js/kakao.min.js"></script> </head> <body> <h3>카카오톡 링크는 카카오톡 앱이 설치되어 있는 모바일 기기에서만 전송 가능합니다.</h3> <a id="kakao-link-btn" href="javascript:;"> <img src="http://dn.api1.kage.kakao.co.kr/14/dn/btqa9B90G1b/GESkkYjKCwJdYOkLvIBKZ0/o.jpg" /> </a> <script> // 사용할 앱의 Javascript 키를 설정해 주세요. Kakao.init('YOUR APP KEY'); // 카카오톡 링크 버튼을 생성합니다. 처음 한번만 호출하면 됩니다. Kakao.Link.createTalkLinkButton({ container: '#kakao-link-btn', label: '카카오링크 샘플에 오신 것을 환영합니다.', image: { src: 'http://dn.api1.kage.kakao.co.kr/14/dn/btqaWmFftyx/tBbQPH764Maw2R6IBhXd6K/o.jpg', width: '300', height: '200' }, webButton: { text: '카카오 디벨로퍼스', url: 'https://dev.kakao.com/docs/js' // 앱 설정의 웹 플랫폼에 등록한 도메인의 URL이어야 합니다. } }); </script> </body> </html>



출처 :
https://developers.kakao.com/docs/js

[JavaScript] Facebook, Twitter share url


*Twitter
- http://twitter.com/share


*Facebook
- http://facebook.com/sharer.php

*Facebook with parameter
- var facebook_url = 'http://www.facebook.com/sharer.php?'+
  'u='+encodeURIComponent('http://google.com/?q=bla')+
  '&amp;t='+encodeURIComponent('Some Page Title');



출처 :
http://stackoverflow.com/questions/7584197/sharer-link-with-parameter-in-url

[JavaScript] LINE App share url (LINE url 공유)

*Format 1
- http://line.me/R/msg/<CONTENT TYPE>/?<CONTENT KEY>

*Format 2
- line://msg/<CONTENT TYPE>/<CONTENT KEY>



출처 :
http://media.line.me/en/

[jQuery] Execute handler -> .trigger()

Execute all handlers and behaviors attached to the matched elements

.trigger( eventType [, extraParameters ] )



출처 :
http://api.jquery.com/trigger/

2014년 7월 16일 수요일

[Node.js] error handling


process.on('uncaughtException', function (err) {
    console.log('Caught exception: ' + err);
});



출처 :
http://nodeqa.com/nodejs_ref/1

2014년 7월 14일 월요일

[Node.js] Node.js, express Install


1. Node.js Install
http://www.nodejs.org/download/

2. go to Modules page
https://www.npmjs.org/ (click 'Modules' at nav)

3. find express
https://www.npmjs.org/package/express

4. install express
$ npm install -g express (-g is global)
(sudo or Administrator)

5. install express-generator
$ npm install -g express-generator (to use '$ express')

6. Create the app
$ express /tmp/foo && cd /tmp/foo

7. Install dependencies:
$ npm install

8. Start the server:
$ npm start




2014년 7월 10일 목요일

[JavaScript] Detect Mobile Browsers



if(navigator.userAgent.match(/(android)|(iphone)|(ipod)|(ipad)/i)) {

}

window.mobilecheck = function() {
var check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
return check; }



출처 :
http://stackoverflow.com/questions/11381673/javascript-solution-to-detect-mobile-browser
http://detectmobilebrowsers.com/

2014년 7월 9일 수요일

[JavaScript] in_array vs. $.inArray vs. indexOf()







http://jsperf.com/in-array-vs-inarray-vs-indexof/5

[jQuery plugin] TouchSwipe (jquery.touchSwipe.js)

클릭으로도 동작해서 테스트시에도 용이함

$(function() {      
      //Enable swiping...
      $("#test").swipe( {
        //Generic swipe handler for all directions
        swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
          $(this).text("You swiped " + direction );  
        },
        //Default is 75px, set to 0 for demo so any distance triggers swipe
         threshold:0
      });
    });



http://labs.rampinteractive.co.uk/touchSwipe/demos/

2014년 7월 8일 화요일

[jQuery] .find() vs .children()

The .find() and .children() methods are similar, except that the latter only travels a single level down the DOM tree.



http://api.jquery.com/find/

[jQuery] jQuery mobile - swipe event

jQuery( .selector ).on( "swipe", function( event ) { ... } )
jQuery( .selector ).on( "swipeleft", function( event ) { ... } )
jQuery( .selector ).on( "swiperight", function( event ) { ... } )



http://api.jquerymobile.com/swipe/

2014년 7월 3일 목요일

[CSS] 터치로 hover css 적용


$(document).ready(function() {
    $('.hover').bind('touchstart touchend', function(e) {
        e.preventDefault();
        $(this).toggleClass('hover_effect');
    });
});



출처 :
http://stackoverflow.com/questions/2851663/how-do-i-simulate-a-hover-with-a-touch-in-touch-enabled-browsers

[MySQL] PROCEDURE를 이용한 loop INSERT

DELIMITER $$

CREATE PROCEDURE myFunction()
BEGIN

    DECLARE i INT DEFAULT 1;

    WHILE (i < 500000) DO
        INSERT INTO `test table` (num, name, email)
        VALUE (i, CONCAT(‘test’, i), HEX(AES_ENCRYPT(CONCAT(‘test’, i, ‘@test.com’), ‘key’)));
        SET i = i + 1;
    END WHILE;
END$$

DELIMITER ;
CALL myFunction();



출처 :
http://teragoon.wordpress.com/2012/11/08/mysql-procedure를-이용한-loop-insert/