Skip to content

Instantly share code, notes, and snippets.

@dpashkevich
dpashkevich / extract_scripts.js
Created September 27, 2012 14:10
Extracts a list of scripts included in current page (JSON-friendly)
// Uses ExtJS but the method names are intuitive and are present in most libraries
Ext.Array.map( Ext.Array.pluck(Ext.query('script'), 'src'), function(v, i) {
return '"' + v.slice('site.com/'.length) + '"';
}).join(',\n')
@dpashkevich
dpashkevich / Directory structure
Created October 8, 2012 10:24
Grunt setup for a big project
Directory structure
SubModule/
css/
...
js/
...
images/
...
@dpashkevich
dpashkevich / domToPre.js
Created November 6, 2012 11:41
DOM tree to Pre converter
/**
* See https://github.com/sellside/pre
*/
/**
* References/todos:
* http://www.lemoda.net/javascript/dump-dom/dump-dom.html
* http://www.howtocreate.co.uk/tutorials/javascript/dombasics
* Use treewalker or nodefilter??
* https://developer.mozilla.org/en-US/docs/DOM/NodeFilter
@dpashkevich
dpashkevich / gist:4031991
Created November 7, 2012 14:41
Whitehouse.gov in Pre markup
/**
* Using experimental, unfinished version of Pre language
* See https://github.com/sellside/pre
*/
html.js.js.borderradius.boxshadow.textshadow.opacity.cssgradients.boxsizing {
xmlns: "http://www.w3.org/1999/xhtml";
xmlns-dc: "http://purl.org/dc/elements/1.1/";
xmlns-ctag: "http://commontag.org/ns#";
lang: "en";
@dpashkevich
dpashkevich / gist:4078082
Created November 15, 2012 11:15
Human-edited JSON use cases
@dpashkevich
dpashkevich / snippets.js
Created November 16, 2012 15:58
Javascript Snippets
/*****************************************************************************
* GENERAL *
* ***************************************************************************/
// Append an empty div to current element
$0.appendChild(document.createElement('div'))
// "Duplicate down" current element
(function() {
@dpashkevich
dpashkevich / gist:4682795
Created January 31, 2013 13:18
Extract any type of archive from the terminal with one function
# extract any type of compressed file
# credit https://coderwall.com/p/arwifq
function extract {
echo Extracting $1 ...
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
@dpashkevich
dpashkevich / .bashrc
Created December 23, 2013 07:52
.bashrc for web developers Copied from https://coderwall.com/p/mgofcw , thanks to @vinitkumar
export EDITOR=vim
# export EDITOR="$HOME/bin/mate -w"
source ~/.bash/aliases
source ~/.bash/paths
# Bashmarks is a simple set of bash functions that allows you to bookmark
# folders in the command-line.
source ~/.bash/bookmarks
- Trailing commas are ok
- No reserved words for property names
- NaN, Infinity, undefined : are all constants
- parseInt() defaults to radix 10
- /regexp/ produces new reg ex object every time
- JSON.parse(), JSON.stringify()
- Function.prototype.bind
- String.prototype.trim
- Array.prototype.every, filter, forEach, indexOf, lastIndexOf, map, reduce, reduceRight, some,
- Date.now()
@dpashkevich
dpashkevich / camelize.d.ts
Created November 19, 2018 04:39
Gists for article "7 outdated excuses to avoid TypeScript"
declare function camelize(s: string): string;