Skip to content

Instantly share code, notes, and snippets.

View kassens's full-sized avatar

Jan Kassens kassens

View GitHub Profile
@kassens
kassens / docs.rb
Created October 15, 2008 15:01
hackish mootools docs server
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] ||= [];
@kassens
kassens / quiz.js
Created October 22, 2008 18:32
js quiz
/*
* 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(){
/*
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
<?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">
(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){
#import <Foundation/Foundation.h>
@interface Settings : NSObject {
NSString *email;
NSString *password;
NSString *server;
BOOL pushesMentions;
BOOL pushesBroadcasts;
<!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>
@kassens
kassens / LICENSE.txt
Created May 23, 2011 11:52 — forked from 140bytes/LICENSE.txt
Fibonacci in 52 bytes.
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
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 / fix-graphql.js
Last active December 14, 2023 21:53
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.
'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;
}