Skip to content

Instantly share code, notes, and snippets.

@JesusLeon
JesusLeon / JS_Parser.js
Last active August 29, 2015 14:25
A small JS {string} parser
function parse(template, data) {
var replacer = function (context) {
return function (placeholder, name) {
return context[name];
};
};
return template.replace(/\{(\w+)\}/g, replacer(data));
}
@JesusLeon
JesusLeon / list_open_apps.applescript
Created July 27, 2015 11:30
List open apps applescript
tell application "System Events"
-- get properties of every process where background only is false
set listOfProcesses to (title of every process where background only is false)
tell me to set selectedProcesses to choose from list listOfProcesses with multiple selections allowed
end tell
@JesusLeon
JesusLeon / Atom_Packages.sh
Last active August 29, 2015 14:25
Atom Packages
# Install linter
apm install lint
# Client-side linters
apm install linter-csslint,linter-htmlhint,linter-jshin,linter-jsonlintt
# Markup linters
apm install linter-js-yaml,linter-xmllint
# Php linters
defaults write com.apple.finder QLEnableTextSelection -bool TRUE;killall Finder
@JesusLeon
JesusLeon / Algfred App - BIG Material Theme Dark
Last active August 29, 2015 14:24
Algfred App - Material Theme
alfred://theme/searchForegroundColor=rgba(235,74,54,1.00)&resultSubtextFontSize=1&searchSelectionForegroundColor=rgba(243,255,248,1.00)&separatorColor=rgba(213,213,213,0.00)&resultSelectedBackgroundColor=rgba(0,224,167,0.78)&shortcutColor=rgba(255,255,255,0.00)&scrollbarColor=rgba(235,74,54,1.00)&imageStyle=9&resultSubtextFont=Helvetica&background=rgba(60,60,60,1.00)&shortcutFontSize=1&searchFontSize=4&resultSubtextColor=rgba(253,255,255,0.15)&searchBackgroundColor=rgba(60,60,60,1.00)&name=BIG%20Material%20Dark&resultTextFontSize=3&resultSelectedSubtextColor=rgba(254,246,255,0.50)&shortcutSelectedColor=rgba(255,255,255,0.51)&widthSize=4&border=rgba(60,60,60,0.00)&resultTextFont=Helvetica&resultTextColor=rgba(243,243,255,0.41)&cornerRoundness=2&searchFont=Helvetica&searchPaddingSize=4&credits=Jesus%20Leon&searchSelectionBackgroundColor=rgba(235,74,54,0.70)&resultSelectedTextColor=rgba(250,255,251,1.00)&resultPaddingSize=4&shortcutFont=Helvetica%20Neue
@JesusLeon
JesusLeon / levenshtein.sql
Created May 11, 2015 08:23
The Levenshtein approximation algorithm ported to SQL
CREATE FUNCTION levenshtein( s1 VARCHAR(255), s2 VARCHAR(255) )
RETURNS INT
DETERMINISTIC
BEGIN
DECLARE s1_len, s2_len, i, j, c, c_temp, cost INT;
DECLARE s1_char CHAR;
-- max strlen=255
DECLARE cv0, cv1 VARBINARY(256);
SET s1_len = CHAR_LENGTH(s1), s2_len = CHAR_LENGTH(s2), cv1 = 0x00, j = 1, i = 1, c = 0;
IF s1 = s2 THEN
@JesusLeon
JesusLeon / Thumb Sizer
Created December 16, 2014 22:25
Change Finder to big Thumb view.
tell application "Finder"
activate
set thisFolder to target of front Finder window
set the current view of front Finder window to icon view
set icon size of icon view options of front Finder window to 196
set arrangement of icon view options of front Finder window to arranged by creation date
close front Finder window
open thisFolder
end tell
git cherry-pick -n <commit> # get your patch, but don't commit (-n = --no-commit)
git reset # unstage the changes from the cherry-picked commit
git add -p # make all your choices (add the changes you do want)
git commit # make the commit!
@JesusLeon
JesusLeon / pretty_time.php
Created August 31, 2012 12:02
PHP Pretty Time addaptation.
/**
* @desc Pretty time
*/
function pretty_time($_DATE_FROM, $_DATE_TO, $_LANG)
{
$SECOND = 1;
$MINUTE = 60 * $SECOND;
$HOUR = 60 * $MINUTE;
$DAY = 24 * $HOUR;
$MONTH = 30 * $DAY;