Skip to content

Instantly share code, notes, and snippets.

View natchiketa's full-sized avatar

Sara Lara natchiketa

View GitHub Profile
@natchiketa
natchiketa / gist:3422148
Created August 22, 2012 03:52
Distance between two coordinates
function distanceBetween( point1, point2 ) {
var xs = 0;
var ys = 0;
xs = point2.x - point1.x;
xs = xs * xs;
ys = point2.y - point1.y;
ys = ys * ys;
@natchiketa
natchiketa / gist:3855626
Created October 8, 2012 23:33
Fetching results, sorting, filter events
/*
* __ _ _
* / _| ___| |_ ___| |__ _ __ __ _ _ __ __ _ _ __ ___ ___
* | |_ / _ \ __/ __| '_ \ | '_ \ / _` | '__/ _` | '_ ` _ \/ __|
* | _| __/ || (__| | | | | |_) | (_| | | | (_| | | | | | \__ \
* |_| \___|\__\___|_| |_| | .__/ \__,_|_| \__,_|_| |_| |_|___/
* |_|
*
* */
@natchiketa
natchiketa / style.scss
Created November 17, 2012 22:49
Some SASS (SCSS) functions and mixins to simplify applying multiple linear and radial gradients to a single element, specifying position and size as well. Includes a usage example (a 'Home' icon).
$webkit: ();
$moz: ();
$ms: ();
$o: ();
$w3c: ();
$pos: ();
$size: ();
$vendors: ($webkit, $moz, $ms, $o, $w3c, $pos, $size);
@function radg($shape, $size, $position, $colorStops, $gpos, $gsize, $scale) {
@natchiketa
natchiketa / pushgrad.py
Created November 17, 2012 23:16
GIMP Python-Fu function to generate CSS gradient based on current selection bounds
def pushgrad(options={}, use_gradient_name=True, image_index=0):
img = gimp.image_list()[image_index]
sel = pdb.gimp_selection_bounds(img)
left, top = sel[1], sel[2]
width = sel[3] - left
height = sel[4] - top
# The following variable, prefix, is what I prefix all of my gradient names in GIMP. Change this to
# fit your situation.
prefix = 'natcss_'
if use_gradient_name:
@natchiketa
natchiketa / pushgrad.scss
Created November 18, 2012 06:13
SASS functions/mixins for layered gradients
/*
pushgrad: gradient layer functions and mixins
*/
$webkit: ();
$moz: ();
$ms: ();
$o: ();
$w3c: ();
$pos: ();
@natchiketa
natchiketa / gist:5288058
Created April 1, 2013 21:51
Checkout a git branch and rsync into place from a working copy on a server. Useful for a dev server, to run remotely from a dev's machine to update
#!/bin/bash
source $(dirname $0)/settings.sh
BRANCH="master";
HELP=false;
while getopts b:d:th option
do
case "${option}"
@natchiketa
natchiketa / vlucht-indy.js
Created April 23, 2013 22:19
Uses Google Maps API v3 to pan between to LatLng coordinates based on the scroll position of the page.
/*
Global
*/
var map, origin, destination,
scrollTop, lastScrollTop,
percentScrollTop, lastPercentScrollTop,
heading, lastHeading,
planeOffset, planeOffsetDiff, lastPlaneOffset;
var CITIES = {
@natchiketa
natchiketa / dabblet.css
Created July 16, 2013 02:59
CSS Puzzle: Reverse the z-order of the <li>s without setting a separate z-index on each one in a way that works in IE9 and up
/**
* CSS Puzzle: Reverse the z-order of the <li>s without setting a separate z-index on each one in a way that works in IE9 and up
*/
li {
list-style: none;
display: inline-block;
padding: 1em 2em 1em 1em;
border: 1px solid rgba(0,0,0,.3);
border-radius: 0 999px 999px 0;
@natchiketa
natchiketa / gcd.sh
Last active December 19, 2015 22:18
Bash function to do a `git clone` and `cd` into the directory. Requires Node, but could be refactored to use easily use pure Bash instead. I put it in my `.bashrc`
function gcd() {
REPONAME=$(node -e "console.log(process.argv[1].match(/.*?\/([a-zA-Z0-9\-]+).git/)[1]);" $1)
git clone $1 && cd "${REPONAME}"
}
@natchiketa
natchiketa / yo-completion.sh
Last active May 25, 2018 20:47
Bash completion for Yeoman generators
# Bash completion for Yeoman generators - tested in Ubuntu, OS X and Windows (using Git bash)
function _yo_generator_complete_() {
# local node_modules if present
local local_modules=$(if [ -d node_modules ]; then echo "node_modules:"; fi)
# node_modules in /usr/local/lib if present
local usr_local_modules=$(if [ -d /usr/local/lib/node_modules ]; then echo "/usr/local/lib/node_modules:"; fi)
# node_modules in user's Roaming/npm (Windows) if present
local win_roam_modules=$(if [ -d $(which yo)/../node_modules ]; then echo "$(which yo)/../node_modules:"; fi)
# concat and also add $NODE_PATH
local node_dirs="${local_modules}${usr_local_modules}${win_roam_modules}${NODE_PATH}"