Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
FranciscoG / iterm-work.scpt
Last active December 22, 2015 05:48
iTerm2 AppleScript script Note: This is very specific to my workflow but you should be able to see how AppleScript works and tweak it for your own needs I use it in tandem with some bash scripts functions in my .bash_profile that go to certain folders.
tell application "iTerm"
activate
#if a terminal exists, use that. if not, create a new one
try
set _term to current terminal
on error
set _term to (make new terminal)
end try
tell _term
@FranciscoG
FranciscoG / .bash_profile
Last active December 22, 2015 05:48
This is for the terminal on OSX (but probably works on Linux too)
export PATH="$PATH:~/bin"
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
# personal functions
@FranciscoG
FranciscoG / fizzbuzz.js
Last active December 23, 2015 00:58
My own simple solution to the FizzBuzz test.
/* FizzBuzz rules:
*
* Write a program that prints the numbers from 1 to 100.
* But for multiples of three print “Fizz” instead of the number
* and for the multiples of five print “Buzz”.
* For numbers which are multiples of both three and five print “FizzBuzz”."
*
*/
@FranciscoG
FranciscoG / findDecimal.js
Created October 1, 2013 20:09
Find how many decimal places a number has. Also please note that I usually start coding these gists as Chrome Snippets so that's why they all are functions attached to window. You don't need to do that
(function(){
window.findDecimal = function(x){
if (typeof x === 'string') {
var x_str = parseFloat(x);
} else if (typeof x === 'number') {
var x_str = x.toString();
} else {
return false; //not a string or a number
}
@FranciscoG
FranciscoG / vertical-align-flex.scss
Last active December 31, 2015 07:09
Using CSS3 to vertical align only 1 child element inside another element with a fallback
@mixin simpleFlex ($align, $child) {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-align:$align;
-webkit-flex-align: $align;
@import "compass/css3/box";
@mixin box-wrap($value: nowrap) {
// No Webkit Box fallback.
-webkit-flex-wrap: $value;
-moz-flex-wrap: $value;
@if $value == nowrap {
-ms-flex-wrap: none;
} @else {
-ms-flex-wrap: $value;
}
@FranciscoG
FranciscoG / Preferences.sublime-settings
Last active June 7, 2016 15:35
Sublime Text 3 personal settings
{
"bold_folder_labels": true,
"caret_extra_bottom": 2,
"caret_extra_top": 2,
"caret_style": "solid",
"color_scheme": "Packages/User/Monokai (SL).tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"font_size": 13,
"highlight_line": true,
@FranciscoG
FranciscoG / tinyRouter.js
Last active August 29, 2015 13:56
A super tiny router. Don't even know if you can call this a router, it's more of an module organizer thingy.
/*
* tinyRouter.js
*
* Super simple JS router class, like super super simple
* doesn't use any regex to match url pathnames or hashes
* just takes a route name, looks for that function that matches it and runs it
* this is really only useful in small projects where you have a few pages and not a ton of JS
* but enough so where you still want to keep things organized
*
* there is one reserved route name
@FranciscoG
FranciscoG / html5tmpl.js
Last active August 29, 2015 13:57
Mini library wrapping HTML5 <template> to make it work sort of like current templating libraries but with less features (for now)
/**
* mini templating library using native html5 templating
* important to note: since html5 templating is basically a wrapper over documentFragment you need to have content nested 1 level deep.
* You can't grab innerHTML of the documentFragment itself, but you can for its children.
* @param {string} id id attribute of the template tag
* @param {object} tmplData data to be added to the template
*
*/
var html5tmpl = (function(id, tmplData) {
@FranciscoG
FranciscoG / maximize.scpt
Created May 5, 2014 14:49
Applescript snippet to maximize current window. Use with Alfred for shortcut keys
-- source http://apple.stackexchange.com/questions/98187/applescript-the-activate-command-makes-application-half-active
-- tested on Mavericks, needs a Security & Privacy -> Accessibility feature turned on.
tell application "System Events" to tell (process 1 where frontmost is true)
click (button 1 where subrole is "AXZoomButton") of window 1
end tell
activate application (path to frontmost application as text)