Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Kassens kassens

View GitHub Profile
@kassens
kassens / fix-graphql.js
Last active Sep 23, 2019
Updates graphql tags that are not within an object literal and not standalone expressions to be wrapped in an object similar to what the Relay babel plugin used to do before simplifying the logic there.
View fix-graphql.js
'use strict';
// To be used with jscodeshift: https://github.com/facebook/jscodeshift
export default function transformer(file, api) {
const j = api.jscodeshift;
if (!file.source.includes('graphql`')) {
return;
}
View remove_commas.py
from __future__ import print_function
import sys
import re
import fileinput
in_graphql = False
for line in fileinput.input(inplace=1):
if '`' in line and not re.search('`.*`', line):
in_graphql = not in_graphql
if in_graphql:
@kassens
kassens / LICENSE.txt
Created May 23, 2011 — forked from 140bytes/LICENSE.txt
Fibonacci in 52 bytes.
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jan Kassens <jan@kassens.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
View selector-bug.html
<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
window.onload = function () {
console.log(document.querySelectorAll('div:nth-child(6) img'));
console.log(document.querySelectorAll('div:nth-child(6) img'));
console.log(document.querySelectorAll('div:nth-child(6) img'));
}
</script>
View gist:362704
#import <Foundation/Foundation.h>
@interface Settings : NSObject {
NSString *email;
NSString *password;
NSString *server;
BOOL pushesMentions;
BOOL pushesBroadcasts;
View gist:134126
(function(write, wrapper, slice, fragment){
document.write = function(){
var id = 'document_write' + $time().toString(36);
var html = slice.call(arguments).join('');
write.call(document, '<span id="' + id + '"></span>');
window.addEvent('domready', function(){
Array.filter(wrapper.set('html', html).childNodes, document.write.filter).each(function(node){
View Request.JSON.xml
<?xml version="1.0" encoding="UTF-8"?>
<class name="Request.JSON">
<description>Wrapped Request with automated sending and receiving of JavaScript Objects in JSON Format.</description>
<extends>Request</extends>
<syntax>var myJSONRemote = new Request.JSON([options]);</syntax>
<arguments>
<argument name="options" type="object" optional="true">See below.</argument>
</arguments>
<options>
<option name="secure" type="boolean" default="true">
View json2.js
/*
http://www.JSON.org/json2.js
2008-11-19
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
View quiz.js
/*
* Author: Jan Kassens
*
* Guess the results and run it in Firebug
* If you got all right with the first try you're a JS Samurai (Ninja is overused)
*/
var tasks = {
'try/finally': function(){
@kassens
kassens / docs.rb
Created Oct 15, 2008
hackish mootools docs server
View docs.rb
require 'rubygems'
require 'maruku'
unless Enumerable.instance_methods.include? "group_by" then
module Enumerable
def group_by(&blck)
result = Hash.new;
each do |x|
k = yield x
result[k] ||= [];