Skip to content

Instantly share code, notes, and snippets.

View doublerebel's full-sized avatar

Charles Phillips doublerebel

View GitHub Profile
@doublerebel
doublerebel / d1-api.js
Created April 17, 2024 20:48
cloudflare-internal:d1-api D1Database API for Cloudflare Workers
// Copyright (c) 2023 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0
class D1Database {
fetcher;
constructor(fetcher) {
this.fetcher = fetcher;
}
prepare(query) {
return new D1PreparedStatement(this, query);
@doublerebel
doublerebel / your_test.go
Last active March 11, 2024 11:34 — forked from epelc/your_test.go
Use pflags and regular `go test` flags in your tests
package yourpackage
import (
goflag "flag"
"fmt"
"os"
"strings"
"testing"
flag "github.com/spf13/pflag"
//
// IPInsetLabel.h
// Instapaper
//
// Created by Marco Arment on 7/23/11.
// Copyright 2011 Instapaper LLC, released to the public domain.
//
#import <UIKit/UIKit.h>
function anonymous(locals, jade) {
var jade_debug = [{ lineno: 1, filename: "themes/doublerebel/views/blog/index.jade" }];
try {
var buf = [];
var jade_mixins = {};
var locals_ = (locals || {}),undefined = locals_.undefined,css = locals_.css,js = locals_.js;
jade_debug.unshift({ lineno: 0, filename: "themes/doublerebel/views/layout.jade" });
jade_debug.unshift({ lineno: 1, filename: "themes/doublerebel/views/blog/index.jade" });
buf.push("<html lang=\"en\">");
jade_debug.unshift({ lineno: undefined, filename: jade_debug[0].filename });
sudo -u git -H "$@"
#!/bin/sh
cd /home/git/repositories/$1
git config --bool core.bare false
git config --path core.worktree $2
git config receive.denycurrentbranch ignore
echo '#!/bin/sh\ngit checkout -f\n' >> hooks/post-receive
chmod +x hooks/post-receive
cd -
@doublerebel
doublerebel / jake_autocomplete.coffee
Last active December 23, 2015 07:49 — forked from cayblood/rake_autocomplete.rb
Autocomplete bash script in Iced CoffeeScript for Jake/Jakefiles
#!/usr/bin/env iced
# Complete jake tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default jake
# to your ~/.bashrc
# Bug-fix from Xavier Shay's version
# ported from Ruby/Rakefile version https://gist.github.com/cayblood/2499921
# to Node/IcedCoffee/Jakefile by doublerebel
# https://gist.github.com/doublerebel/6603667
@doublerebel
doublerebel / signasdebug.sh
Created September 4, 2013 21:07
Sign apk with Android default debug keystore. Required for TestFlight module to recognize build as debug. Titanium Mobile signs with its own tirocks keystore by default.
cp app-unsigned.apk temp.apk
jarsigner -verbose -keystore ~/.android/debug.keystore -digestalg SHA1 -sigalg MD5withRSA -storepass android -keypass android temp.apk androiddebugkey
$ANDROID_SDK/tools/zipalign -v 4 temp.apk temp.apkz
mv temp.apkz $1 && rm temp.apk
pointInPoly = (point,poly) ->
segments = for pointA, index in poly
pointB = poly[(index + 1) % poly.length]
[pointA,pointB]
intesected = (segment for segment in segments when rayIntesectsSegment(point,segment))
intesected.length % 2 != 0
rayIntesectsSegment = (p,segment) ->
[p1,p2] = segment
[a,b] = if p1.y < p2.y
@doublerebel
doublerebel / routeexample-app.js
Created March 8, 2013 16:55
Example of Tiger routing in plain JS (for Titanium Mobile)
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',