Skip to content

Instantly share code, notes, and snippets.

View gion's full-sized avatar
💭
🦄 🌈 🍦

Bogdan Gradinariu gion

💭
🦄 🌈 🍦
View GitHub Profile
@gion
gion / test.js
Last active August 29, 2015 14:17
alert(4);
@gion
gion / facebook.invite-all.js
Created January 20, 2015 09:51
a simple script to run in console in order to send an invite(for a page) to all your friends
[].slice.call(document.querySelectorAll('span'), 0).filter(function(el){return el.innerText === 'Invite';}).forEach(function(el){el.click();})
@gion
gion / less-recess-grunt.js
Created October 9, 2014 08:13
how to config grunt to use less instead of css/sass (using grunt-recess)
/*!
include the following in the package.json file:
"grunt-recess": "~0.6.1",
"grunt-contrib-less": "~0.11.0"
and then run `npm install/update`
*/
//...
// js interview test application
;(function(global, app, undefined) {
function assert(testResult, okMsg, failMsg) {
if(testResult) {
console.log('[assert passed]', okMsg);
} else {
console.error('[assert failed]', failMsg || okMsg);
}
@gion
gion / post-merge.sh
Created April 2, 2014 10:11
This is a pull (actually a merge) git hook that automatically installs bower and node dependencies if the bower.json or packge.json files have been changed in the targeted commit has
#!/bin/sh
#Inspired by http://www.snip2code.com/Snippet/15944/git-hook-for-bower-install-and-npm-insta
#Notice: This won't run at git fetch. since fetch doesn't merge anything
#Installation:
# copy this script with the name:`post-merge.sh` to your project root folder
# symlink it to the ./git/hooks/post-merge: `ln post-merge.sh .git/hooks/post-merge
#You should have bash (windows users, means cygwin/mingw anything that works for you
#Based on the instructions here: https://oknesset-devel.readthedocs.org/en/latest/workflow.html#before-coding
@gion
gion / ie-digest-error
Created January 22, 2014 15:28
the famous ie 10 iteration infinite loop error
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: function $locationWatch() {\n var oldUrl = $browser.url();\n var currentReplace = $location.$$replace;\n\n if (!changeCounter || oldUrl != $location.absUrl()) {\n changeCounter++;\n $rootScope.$evalAsync(function() {\n if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n defaultPrevented) {\n $location.$$parse(oldUrl);\n } else {\n $browser.url($location.absUrl(), currentReplace);\n afterLocationChange(oldUrl);\n }\n });\n }\n $location.$$replace = false;\n\n return changeCounter;\n }; newVal: 20; oldVal: 19","fn: function(context) {\n try {\n for(var i = 0, ii = length, part; i<ii; i++) {\n if (typeof (part = parts[i]) == 'function') {\n part = part(context);\n if (trustedContex
@gion
gion / sharer.php
Last active December 27, 2015 09:19
This is a dynamic file that represents all the data needed by a social network (such as facebook or twitter) to render all the details of a shared link
<?php
function get($k) {
return isset($_GET[$k]) ? htmlentities($_GET[$k]) : '';
}
$hasData = count($_GET) > 0;
$url = get('url');
$title = get('title');
$description = get('description');
@gion
gion / jquery.stateManager.js
Last active December 23, 2015 08:19
This is a sample `stateManager` object (that depends on jQuery). It's main goal is to make it easy to control your application with css classes used as states.
//https://gist.github.com/gion/6606933
;(function(global, $, undefined){
var stateManager = function(){
this.root = null;
this.prefix = null;
this.settings = {};
this.init();
};
@gion
gion / rAF.js
Created September 16, 2013 07:44 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@gion
gion / gist:5633408
Last active December 17, 2015 15:39
<?php
function add_custom_taxonomies() {
// Add new "Preparation Time" taxonomy to out Recipes (Posts)
register_taxonomy('Preparation Time', 'post', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Preparation Times', 'taxonomy general name' ),
'singular_name' => _x( 'Preparation Times', 'taxonomy singular name' ),