Skip to content

Instantly share code, notes, and snippets.

<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event)
{
alert("RECEIVED!");
if (event.origin !== "http://localhost:3000")
return;
@joshski
joshski / monitor.html
Created March 25, 2014 17:42
Monitor remote websites, in style
<html>
<body>
<h1 id="heading"></h1>
<iframe id="frame" src="about:blank" style="width: 100%; height: 100%"></iframe>
<script type="text/javascript">
var urls = [
'http://httpbin.org/status/418',
@joshski
joshski / git-flow
Created March 18, 2014 11:52
My Git flow (am I weird?)
git checkout master
git pull origin master
[run tests]
[write failing test]
[make test pass]
git checkout -b feature_x
git add .
git commit -m "Feature X"
[refactor]
[run tests]
@joshski
joshski / bad-hint-paths.ps1
Last active October 12, 2017 08:26
Find bad hint paths in csproj files
get-childitem . -include *.csproj -rec | select-string -pattern "<HintPath>[^<]+</HintPath>" | % { $_ -replace '</?HintPath>',"" } | % { write-host $_; $_ } | % { $_ -replace '[^\\]*.csproj:\d+:',"" } | % { $_ -replace '\s+','' } | % { resolve-path $_ }
@joshski
joshski / react-component.pogo
Last active August 29, 2015 13:56
React component in pogo
module.exports = {
render () =
div (
h1 { id = 'main_heading' } (props.heading)
p (props.introduction)
)
}
import minecraft
import block
import time
mc = minecraft.Minecraft.create()
direction = 'none'
playerTilePos = mc.player.getTilePos()
mc.setBlocks(playerTilePos.x - 25, playerTilePos.y, playerTilePos.z - 25, playerTilePos.x + 25, playerTilePos.y + 2, playerTilePos.z + 25, block.AIR)
@joshski
joshski / gist:8207912
Created January 1, 2014 13:06
bug in npm 'xpath'?
require 'nokogiri'
Nokogiri::HTML('<z><a /><b /><a /><b /><b /><b /><a /><c><a /><b /></c></z>').css("a + b")
=> [#<Nokogiri::XML::Element:0x3fdf7d0c0a34 name="b">, #<Nokogiri::XML::Element:0x3fdf7d0c0688 name="b">, #<Nokogiri::XML::Element:0x3fdf7d0c046c name="b">]
Nokogiri::HTML('<z><a /><b /><a /><b /><b /><b /><a /><c><a /><b /></c></z>').xpath("//a/following-sibling::*[1]/self::b")
=> [#<Nokogiri::XML::Element:0x3fdf7d0cc294 name="b">, #<Nokogiri::XML::Element:0x3fdf7d0cc08c name="b">, #<Nokogiri::XML::Element:0x3fdf7d0cbe70 name="b">]
$('<z><a /><b /><a /><b /><b /><b /><a /><c><a /><b /></c></z>').find('a + b');
Object[b, b, b]
echo
echo "DELETE INDEX"
echo
curl -w "\r\n" -X DELETE http://localhost:9200/temp-index
echo
echo "CREATE MAPPINGS"
echo
curl -w "\r\n" -X POST http://localhost:9200/temp-index -d '{"mappings":{"product":{"properties":{"name":{"type":"string","analyzer":"snowball"},"tags":{"type":"string","index":"not_analyzed"},"url":{"type":"string","index":"not_analyzed"},"image":{"type":"string","index":"not_analyzed"},"class":{"type":"string","index":"not_analyzed"},"publisher":{"type":"string","index":"not_analyzed"}}}},"settings":{}}'
@joshski
joshski / flame.lua
Created April 21, 2013 10:52
Generates a little flame. Works in Codea.
-- a little flame in a functional style
function particle(step, style, t)
local newStyle = step(style, t)
return {
style = newStyle,
next = function()
return particle(step, newStyle, t + 1)
end
}
@joshski
joshski / gist:4596443
Created January 22, 2013 17:22
capybara mechanize headers
# capybara '1.1.2
require 'capybara'
require 'capybara/dsl'
require 'capybara/mechanize'
Capybara.default_driver = :mechanize
Capybara.app_host = 'http://httpbin.org'
include Capybara::DSL