Skip to content

Instantly share code, notes, and snippets.

window.loadScripts = function(scripts){
var src;
var script;
var pendingScripts = [];
var firstScript = document.scripts[0];
// Watch scripts load in IE
function stateChange() {
// Execute as many scripts in order as we can
var pendingScript;
@gustafnk
gustafnk / inline-script.js
Last active September 5, 2016 06:24
Avoid flickering of hincludes
<!-- Put this code before the first hinclude or in the <head> element -->
<script>
<!-- https://gist.github.com/egeorjon/6755681 -->
document.documentElement.className = document.documentElement.className.replace( /(?:^|\s)no-script(?!\S)/g , '' )
</script>
<style>
hinclude:not(.included) {
visibility: hidden;
}
@gustafnk
gustafnk / h-include.js
Last active March 2, 2016 13:47
A custom element port of hinclude.js
/*
hinclude.js -- HTML Includes (version 0.9.5)
Copyright (c) 2005-2012 Mark Nottingham <mnot@mnot.net>
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
@gustafnk
gustafnk / post_install.sh
Last active October 19, 2020 01:59
Post install for Manjaro XFCE Edition
####################################################
# Post install for Manjaro XFCE Edition
# Do not run this as a shell script
####################################################
## Install essentials
sudo pacman -S vim git curl
git config --global core.editor "vim"
## Install rvm (ruby)
@gustafnk
gustafnk / twitter_list.rb
Last active August 29, 2015 13:56
Get twitter list in ruby
require 'twitter'
require 'pry'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
@gustafnk
gustafnk / core.clj
Last active December 28, 2015 14:29
Play a sequence of chords on a mooger, looping through the list of chords.
(ns insane-noises.core (:use [overtone.live]
[overtone.inst.synth]))
(def metro (metronome 64))
(def chords [[:C3 :E3 :G3 :B3] [:F3 :A3 :C3 :E4]])
(defn play-chord [chord] (doall (map (fn [n] (mooger n :amp 0.9)) (map note chord))))
(defn chord-player
[beat pids]
@gustafnk
gustafnk / poll_twitter_favorites.js
Last active December 28, 2015 12:09
List all your twitter favorites - slow and dirty. You must be on your twitter favorites page. When done, do "Inspect Element" and copy the html tag, then paste it into a text editor and save.
var poll = function(){
window.scrollTo(0, document.body.scrollHeight);
setTimeout(function(){ poll() }, 500);
};
poll();
@gustafnk
gustafnk / EditSpike.cshtml
Created September 12, 2012 19:35
Using RazorGenerator and CsQuery to assert on Razor views
@model MyNamespace.Models.EditViewModel
<div>
<h1>Hello world</h1>
<span class="foo">@Model.Bar</span>
</div>
@gustafnk
gustafnk / gist:717856
Created November 27, 2010 12:31
Playing with CoffeeScript and underscore.coffee
# Check CoffeeScript
square = (x) -> x * x
puts "'2' squared: #{square 2}"
# See if underscore.coffee is loaded
puts "underscore version: #{_.VERSION}"
stateful = (value, state) ->
bind = (operation) ->
stateful(operation.call(bind, value), bind.state)
bind.value = value
bind.state = state
bind
p = stateful(3, "This is the state")((i) -> ++i)((i) -> this.state += "altered"; i * 10)((i) -> i + 2)
console.log("Value: " + p.value + "; state: " + p.state);