Skip to content

Instantly share code, notes, and snippets.

@codexico
codexico / social.js
Created April 23, 2014 13:30
share functions
function shareFacebook(title, summary, url, image) {
url = ['https://www.facebook.com/sharer/sharer.php?s=100&p[summary]=', encodeURI(summary), '&p[title]=', encodeURI(title), '&p[url]=', encodeURI(url), '&p[images][0]=', encodeURI(image)];
window.open(url.join(''), 'facebook', 'height=300,width=600');
}
function shareFacebookFBui(options, callbackShare) {
// http://developers.facebook.com/docs/reference/dialogs/feed/
var defaults = {
method: 'feed',
@codexico
codexico / log_args
Created April 21, 2014 20:02
javascript log arguments
function log_args () {
console.log([].slice.call(arguments))
}
@codexico
codexico / gist:10409140
Created April 10, 2014 18:23
show hidden files on finder
defaults write com.apple.Finder AppleShowAllFiles TRUE; killall Finder
@codexico
codexico / gist:8572143
Last active January 4, 2016 04:59
CSS pointer-events ============= CSS' pointer-events property effectively disable an element when the value is none but otherwise allow the element to function per usual when the value isn't none. Pointer-events even prevent JavaScript events from firing. Click on that element and any addEventListener callback you've placed on the element will n…
.disabled { pointer-events: none; }
@codexico
codexico / gist:8568280
Created January 22, 2014 22:02
char list to accept from user
function inputOnlyLetters () {
var re_letters= /^[ ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáãÃÀÁéèÈÉíìÍÌïÏóòõÕÓÒúùÚÙüÜ]+$/gi;
var re_not_letters= /[^ ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáãÃÀÁéèÈÉíìÍÌïÏóòõÕÓÒúùÚÙüÜ]/gi;
$('.not-number').on('keyup', function() {
var input = this;
// user needs some time to write chars that need two strokes, like ç => ' + c
window.setTimeout(function(){
<snippet>
<content><![CDATA[
console.log('${1:this} = ', ${1:snippet});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>clog</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
</snippet>
<snippet>
<content><![CDATA[
console.log(${1:this});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>log</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@codexico
codexico / stringWidth stringWordCrop
Created April 9, 2013 22:48
Crop string by width and word and append " ...".
// http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript
function stringWidth(s, className) {
var c = className || "",
o = $('<div class="' + c + '">' + s + '</div>')
.css({'position': 'absolute', 'float': 'left', 'white-space': 'nowrap', 'visibility': 'hidden'})
.appendTo($('body')),
w = o.width();
o.remove();
@codexico
codexico / utils.js
Created April 4, 2013 15:59
getUrlParameter javascript
var getURLParameter = function (name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[undefined,""])[1].replace(/\+/g, '%20'))||null;
};
@codexico
codexico / pvt.fb.js
Created April 1, 2013 16:52
scrollTo animate Facebook
// http://stackoverflow.com/questions/7193425/how-do-you-animate-fb-canvas-scrollto
function scrollTo(y){
FB.Canvas.getPageInfo(function(pageInfo){
$({y: pageInfo.scrollTop}).animate(
{y: y},
{duration: 1000, step: function(offset){
FB.Canvas.scrollTo(0, offset);
}
});