Skip to content

Instantly share code, notes, and snippets.

View DekusDenial's full-sized avatar

D Morty k DekusDenial

  • United States
View GitHub Profile
@DekusDenial
DekusDenial / Gruntfile.coffee
Created June 16, 2013 04:17
More comprehensive Gruntfile
module.exports = (grunt) ->
grunt.initConfig
appDir: "./app"
srcDir: "<%= appDir %>/src"
contentDir: "<%= appDir %>/content"
templateDir: "<%= appDir %>/templates"
vendorDir: "<%= appDir %>/vendor"
cssDir: "<%= appDir %>/stylesheets"
testDir: "./test"
@DekusDenial
DekusDenial / prime.js
Created June 17, 2013 05:00
Prime Number
function Prime() {
this.prime = 1;
}
Prime.prototype.isPrime = function(num) {
var result = true, maxToCheck = Math.ceil(Math.sqrt(num)); // integer number comparison is faster
if (num & 1) { // if odd number
for (var f = 3; f <= maxToCheck; f += 2) {
if (!(result = !!(num % f))) return false;
@DekusDenial
DekusDenial / Gruntfile.js
Created June 18, 2013 05:49
Gruntfile for brackets
/*
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@DekusDenial
DekusDenial / Gruntfile.js
Created June 28, 2013 13:55
minimal gruntfile
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
meta : {
js : [
'js/*.js',
'lib/*.js'
],
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@DekusDenial
DekusDenial / fetch_upstream
Created October 3, 2013 03:37
First, clone your forked repo. Second, set remote upstream to be the repo your repo forking from. Last, rebase the current HEAD with the remote HEAD
#!/usr/bin/env sh
repo=$( echo $1 | sed -E 's/^.*\///' | sed -E 's/\.git//' )
echo "\n<<<<<<<<< Cloning [${repo}] from [${1}] >>>>>>>>>"
T1=$(date +%s)
git clone $1 && cd $repo
HEAD=$( git rev-parse --abbrev-ref HEAD )
@DekusDenial
DekusDenial / rebase_upstream
Created October 3, 2013 03:39
Loop through all the forked repos, update the remote upstream and rebase it with the current local HEAD. With '-f' flag to push after performing the tasks above, for each repo.
#!/usr/bin/env sh
push=0
if [[ $# -eq 1 && $1 -eq '-f' ]]; then
push=1
fi
T1=$(date +%s)
cwd=$(pwd)
@DekusDenial
DekusDenial / Y.js
Created October 7, 2013 04:36
Y Combinator in Javascript
function Y(f) {
var g = function(h) {
return function(x) {
return f(h(h))(x);
};
};
return g(g);
}
@DekusDenial
DekusDenial / mytheme.zsh-theme
Created November 17, 2013 06:11
my zsh theme
# PROMPT='
# %{$fg[red]%}⌈ %{$fg[white]%}%n%{$fg[red]%} ⌋ %{$fg[blue]%}➤➤➤ %{$fg[red]%}❝ %{$fg[yellow]%}$(get_pwd) %{$fg[red]%}❞ %{$(put_spacing)%}%{$fg[cyan]%}%{$(git_prompt_info)%}
# %{$fg[magenta]%}%i %{$fg[red]%}⚡%{$fg[red]%}%@ %{$fg[red]%}➜ %{$reset_color%}'
PROMPT='
%{$fg[red]%}⌈ %{$fg[white]%}%n%{$fg[red]%} ⌋ %{$fg[blue]%}➤➤➤ %{$fg[red]%}❝ %{$fg[yellow]%}$(get_pwd) %{$fg[red]%}❞ %{$fg[cyan]%}%{$(git_prompt_info)%}
%{$fg[magenta]%}%i %{$fg[red]%}⚡%{$fg[red]%}%@ %{$fg[red]%}➜ %{$reset_color%}'
function get_pwd() {
echo "${PWD/$HOME/~}"
(function () {
'use strict';
var DEFAULT_MAX_DEPTH = 6;
var DEFAULT_ARRAY_MAX_LENGTH = 50;
var seen; // Same variable used for all stringifications
Date.prototype.toPrunedJSON = Date.prototype.toJSON;
String.prototype.toPrunedJSON = String.prototype.toJSON;