Skip to content

Instantly share code, notes, and snippets.

Rune runeh

  • Oslo
Block or report user

Report or block runeh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View client.js
const client = sanityClient({
projectId: 'p354jyup',
dataset: 'main',
useCdn: true,
});
// needs polyfill
const origin = window.location.origin
client.clientConfig.cdnUrl = `${origin}/sanity`;
View mark console error test
$ var personPromise = new Promise((resolve, reject) => {
setTimeout(function() {
reject('oh no');
}, 1000);
});
<await(person from personPromise)>
<div>Works</div>
<await-error>something went wrong</await-error>
</await>
View getElementsByAttribute
function getElementsByAttribute(attrName, root) {
root = root || document;
if (root.querySelectorAll) {
return root.querySelectorAll("[" + attrName + "]");
}
else {
var ret = [];
var elems = root.getElementsByTagName("*");
for (var n = 0, ele; ele = elems[n++];) {
if (ele.hasAttribute(attrName)) {
View controllers.js
app.controller( 'AppCtrl', function ($scope, socket) {
socket.onopen(
function(){
console.log('Socket is connected :D')
}
)
socket.onclose(
function(){
console.log('Socket is disconnected :(')
}
View git-loglive
#!/bin/bash
while :
do
clear
lines=`tput lines`
lines=`expr $lines - 2`
git --no-pager log --graph --pretty=oneline --abbrev-commit --decorate --all --color $* | head -n $lines
sleep 1
done
View unleashstream.js
var request = require('request-promise');
var highland = require('highland');
var promiseToStream = highland;
var arrayToStream = highland;
var pollerToStream = highland;
function eventTime(event) {
return new Date(event.createdAt).getTime();
}
View h2o_http2_proxy.yaml
listen:
port: 443
ssl:
certificate-file: /tmp/h2o/localhost.crt
key-file: /tmp/h2o/localhost.key
hosts:
"localhost":
paths:
"/":
View gist:262455
equal(alert, {foo: 1, bar: 2}, "Function is not a dict")
1. Function is not a dict, expected: {
"foo": 1,
"bar": 2
} result: function alert(){
[code]
}
View missing_modules.py
"""Ban some modules from being importable inside the context
For example:
with missing_modules("sys"):
try:
import sys
except ImportError:
print "sys not found"
You can’t perform that action at this time.