Skip to content

Instantly share code, notes, and snippets.

View freshtonic's full-sized avatar
🎯

James Sadler freshtonic

🎯
  • Sydney, Australia
View GitHub Profile
@jcgregorio
jcgregorio / How_to_use.html
Last active July 17, 2023 14:44
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@damncabbage
damncabbage / decrypt_with.py
Last active January 29, 2017 20:45
A file-decryption filter using Ansible Vault's decryption mechanism and an arbitrary password.
# Place in <your-playbook-root>/filter_plugins/decrypt_with.py
from ansible import errors
from ansible.utils.vault import VaultLib
def decrypt_with(data, password):
vault = VaultLib(password=password)
if data is None:
raise errors.AnsibleFilterError("data is missing; cannot decrypt")
elif len(data) == 0:
@philoye
philoye / nyc-recommendations.markdown
Last active August 29, 2015 14:06
NYC Recommendations

My NYC Recommendations

It is a bit out of date in places (I haven’t lived in NYC since 2007). Make sure you google places to make sure they are still open:

DRINKS

Sunset drinks at the Boom Boom room at the Standard Hotel. It is in the meat packing district. Overpriced cocktails but stupendous view.

@JonRowe
JonRowe / pre-recieve-hook
Last active August 29, 2015 13:57
A git pre-receive hook for Ruby deploying.
#!/bin/bash
# Let's deploy...
echo "Deploying..."
echo "Deploying as: `whoami`"
# turn on failing script on any command fail
set -e
set -o pipefail
@nkpart
nkpart / fuzzy_window_select.tmux.conf
Last active August 29, 2015 13:56
Selecta + Tmux
# Creates a new window to run selecta over list-windows, then selects the result.
bind-key g new-window -n "__SELECTA__" "tmux list-windows | grep -v __SELECTA__ | selecta | sed s/:.*// | xargs -I {} tmux select-window -t {}"
# The same in a split (this is probably better). 21 is how high selecta is by default, 1 line for the prompt, 20 for results
bind-key g split-window -l 21 "tmux list-windows | selecta | sed s/:.*// | xargs -I {} tmux select-window -t {}"
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
module Primes where
open import Level using (_⊔_)
open import Coinduction
open import Function
open import Data.Empty
open import Data.Unit
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Divisibility
@pat
pat / gist:6423135
Created September 3, 2013 12:15
Australian Politics Primer - September 3rd 2013

Disclaimer: as you’ve likely picked up from Twitter, I’m obviously biased. I’m not going to make much of an attempt to avoid that.

Parties, History and Houses

The Australian Federal Election is happening this Saturday. The likely outcome is that our new Prime Minister will be Tony Abbott, a conservative, bible-loving, homophobic misogynist. He’s the leader of the Liberal Party, who aren’t really very good at being liberal. Hence, in Australia, there’s the distinction between big-L Liberal and small-l liberal. The Liberal Party has an ongoing coalition with the National Party, who are also conservatives (perhaps moreso) with a focus on the bush (anywhere that isn’t a city). Together they’re known as the Coalition (yes, I know, it’s imaginative, but they save their creativity for how to best fuck over refugees, women, the poor, and generally anyone whose skin colour isn’t white).

They’re not in power at the moment though – the party running the country currently is the Australian Labor Party (a

@toolmantim
toolmantim / Makefile
Last active December 5, 2022 23:14
An example of using Make instead of Grunt for fast, simple and maintainable front-end asset compilation.
# A simple Makefile alternative to using Grunt for your static asset compilation
#
## Usage
#
# $ npm install
#
# And then you can run various commands:
#
# $ make # compile files that need compiling
# $ make clean all # remove target files and recompile from scratch
record = Post.new(:title => 'Yay', :body => 'This is some insert SQL')
# easiest way to achieve this is by calling protected #arel_attributes_values (tested in
# rails 3.2.13). the alternative is to build the entire insert statement using arel >_>
record.class.arel_table.create_insert \
.tap { |im| im.insert(record.send(:arel_attributes_values, false)) } \
.to_sql