Skip to content

Instantly share code, notes, and snippets.

View greymechanic's full-sized avatar
🛠️
building

Andrew Dash greymechanic

🛠️
building
View GitHub Profile
@bennadel
bennadel / dom-state.htm
Created September 19, 2015 00:34
Setting The State Based On Rendered DOM Elements In ReactJS
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>
Setting The State Based On Rendered DOM Elements In ReactJS
</title>
<link rel="stylesheet" type="text/css" href="./demo.css"></link>
@MoOx
MoOx / svgicon.css
Last active December 3, 2018 08:50
Svg icons with React.js with webpack loader (svg: raw-loader)
.SVGIcon {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
/* fix webkit/blink poor rendering issues */
transform: translate3d(0,0,0);
/* it's better defined directly because of the cascade shit
width: inherit;
height: inherit;
@bomberstudios
bomberstudios / Change Font.sketchplugin
Last active May 20, 2024 03:42
Change font family for all text layers in Sketch
// Change font (ctrl a)
var doc = context.document,
selection = context.selection,
font_name = [doc askForUserInput:"Font name:" initialValue:"Arial"];
function check_layer(layer){
log(layer)
var className = layer.className()
log("Checking layer " + layer + " of klass: " + className)
if (className == "MSTextLayer") {
@hyperking
hyperking / Pelican Jinja Date Extension
Last active November 8, 2016 16:49
Pelican Jinja Date extension and conditional for comparing current datetime to object date.
This will format python datetime as a string to be used within jinja conditionals for comparing current date to article date using pelican app.
1. Create a file named jinjaext.py
2. paste the following snippet
def convertdate(datetime, format='%a-%d-%m-%Y'):
return datetime.date().strftime(format)
3. Add the following line to your config file
@paulkoegel
paulkoegel / mixed_layout.md
Last active December 11, 2015 19:28
Extended MarionetteLayout to which you can pass an array of region names and View instances (via .addViews()); automatically creates the required region DOM containers. SEE BELOW FOR CODE.

MixedLayout

MixedLayouts are our custom extension of MarionetteLayouts which we use to wrap a heterogeneous collection of Backbone Views. This allows us to change the contents of complex pages all at once while preventing zombie views and leaving certain static elements like Navigation, Toolbar, or FooterViews on the page.

Rationale and Raison d'être

Marionette's Composite and CollectionViews are limited to rendering all their associated collection's items with the same ItemView. For our homepage, e.g., we need to encapsulate various Views - TopView, CategoryView, QuoteOfTheDayView etc. - in dynamic order into one Marionette View construct that can be .closed() to prevent zombie views. The Marionette view component designed to encapsulate heterogeneous subviews is the Layout. However, we cannot use a vanilla MarionetteLayout for the homepage because a Layout relies

@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@boucher
boucher / gist:1750368
Created February 6, 2012 07:07 — forked from saikat/gist:1084146
Stripe sample checkout form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Sample Form</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<script type="text/javascript">
@robflaherty
robflaherty / svg-path-to-json.py
Created January 15, 2012 16:39
Extract SVG paths and convert to JSON for use with Raphael.js
from xml.dom import minidom
import json
config = {
'svg_file' : 'map.svg',
'js_file' : 'map.js',
'js_var' : 'svgMap'
}
svg = minidom.parse(config['svg_file'])
@cjus
cjus / jsonval.sh
Created June 26, 2011 17:42
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`