Skip to content

Instantly share code, notes, and snippets.

View jeffdrumgod's full-sized avatar

Jefferson Rafael Kozerski jeffdrumgod

View GitHub Profile
@jeffdrumgod
jeffdrumgod / test.txt
Created May 16, 2012 02:50
teste: teste
test
@jeffdrumgod
jeffdrumgod / _pems.scss
Created November 3, 2012 14:52 — forked from arielsalminen/_pems.scss
PX to EMs conversion in Sass
/* See http://mrdanadams.com/2012/pixel-ems-css-conversion-sass-mixin/ */
/* Default font size in pixels if not overridden. */
$baseFontSize: 16;
/* Convert PX units to EMs.
Ex: margin-right: pem(16);
*/
@function pem($pxval, $base: $baseFontSize) {
@return #{$pxval / $base}em;
// Example:
JavaScript.load("/javascripts/something.js");
// With callback (that’s the good thing):
JavaScript.load("http://www.someawesomedomain.com/api.js", function() {
API.use(); // or whatever api.js provides ...
});
#!/usr/bin/env python
from pypodio2 import api
import sys, shutil, os, json
c = api.OAuthClient(sys.argv[1],sys.argv[2], sys.argv[3], sys.argv[4])
orginfo = c.transport.get(url = '/org/')
def writerawtext(filename, data):
try:
/*
https://gist.github.com/jeffdrumgod/5788907
http://stackoverflow.com/a/2866613
decimal_sep: character used as deciaml separtor, it defaults to '.' when omitted
thousands_sep: char used as thousands separator, it defaults to ',' when omitted
*/
Number.prototype.toMoney = function(decimals, decimal_sep, thousands_sep)
{
var n = this,
/*! Copyright 2011, Ben Lin (http://dreamerslab.com/)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 1.0.2
*
* Requires: jQuery 1.2.3+
*/
$.preload = function(){
var tmp = [], i = arguments.length;
// reverse loop run faster
function getTagFromHtmlText(html, tagFind, attrFind, attrValueFind, returnResult, all){
html = html || '',
reg = '';
if(all === undefined){
all = false;
}
html = html.replace(/<!--[\s\S]*?-->/g, ''); // remove comments
if(attrFind === undefined || attrFind === false){
reg = new RegExp('<'+tagFind+'\\b[^>]*(\\1)([^>]*/>|[^>]*>((?:(?:(?!<'+tagFind+'[^>]*>|<\/'+tagFind+'>)[\\s\\S])+|<'+tagFind+'[^>]*>([\\s\\S]*?)<\/'+tagFind+'>)*)<\/'+tagFind+'>)','gi');
if("function"!=typeof(String.prototype.replaceSpecialChars)) String.prototype.replaceSpecialChars=function(){var _replace={"ç":"c","æ":"ae","œ":"oe","á":"a","é":"e","í":"i","ó":"o","ú":"u","à":"a","è":"e","ì":"i","ò":"o","ù":"u","ä":"a","ë":"e","ï":"i","ö":"o","ü":"u","ÿ":"y","â":"a","ê":"e","î":"i","ô":"o","û":"u","å":"a","ã":"a","ø":"o","õ":"o","u":"u","Á":"A","É":"E","Í":"I","Ó":"O","Ú":"U","Ê":"E","Ô":"O","Ü":"U","Ã":"A","Õ":"O","À":"A","Ç":"C"};return this.replace(/[à-ú]/g,function(a){if(typeof(_replace[a])!="undefined") return _replace[a]; return a;});};
function truncate_words($text, $limit, $ellipsis = '...') {
$words = preg_split("/[\n\r\t ]+/", $text, $limit + 1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_OFFSET_CAPTURE);
if (count($words) > $limit) {
end($words); //ignore last element since it contains the rest of the string
$last_word = prev($words);
$text = substr($text, 0, $last_word[1] + strlen($last_word[0])) . $ellipsis;
}
return $text;
}
/* https://gist.github.com/jeffdrumgod/5997078
* querySelectorObj
*
* Return object with parameters.
* Return null if result or query is empty.
*
* var query = only query, not full url
* var key = looking for that key and returns its value if it finds
* var value = Search this value and returns the key, if it finds