Skip to content

Instantly share code, notes, and snippets.

View feyeleanor's full-sized avatar

Eleanor McHugh feyeleanor

View GitHub Profile
//https://habr.com/post/213515/
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB,
IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction,
baseName = "baseName",
storeName = "storeName";
function logerr(err){
console.log(err);
@dahlia
dahlia / lisp.rb
Created September 2, 2010 07:52
30 minutes Lisp in Ruby
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active April 4, 2024 02:00
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@FiloSottile
FiloSottile / 32.asm
Last active March 23, 2024 12:28
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4
@deiu
deiu / webcryptoapi.html
Last active January 7, 2024 21:18
Web Crypto API example: RSA keygen & export & import & sign & verify & encrypt & decrypt
<!-- MIT License -->
<html>
<head>
<script>
function generateKey(alg, scope) {
return new Promise(function(resolve) {
var genkey = crypto.subtle.generateKey(alg, true, scope)
genkey.then(function (pair) {
resolve(pair)
})
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@greenido
greenido / notes-IndexedDB.html
Created September 23, 2012 09:37 — forked from cfjedimaster/gist:2499973
Simple indexedDB example that will work both in Chrome and FF
<!DOCTYPE html>
<head>
<script>
var db;
// until we won't need this prefix mess
var indexedDB = window.indexedDB || window.webkitIndexedDB
|| window.mozIndexedDB || window.msIndexedDB;
var IDBTransaction = window.IDBTransaction ||
window.webkitIDBTransaction;
@ryandabler
ryandabler / IndexedDB example.js
Created May 2, 2018 01:50
Working example of an IndexedDB implementation to handle transactions surrounding a fake invoice database
const request = window.indexedDB.open("database", 1);
// Create schema
request.onupgradeneeded = event => {
const db = event.target.result;
const invoiceStore = db.createObjectStore("invoices", { keyPath: "invoiceId" });
invoiceStore.createIndex("VendorIndex", "vendor");
const itemStore = db.createObjectStore("invoice-items", { keyPath: ["invoiceId", "row"] });
@jdiamond
jdiamond / indexeddb.html
Created September 16, 2012 22:25
IndexedDB Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IndexedDB Example</title>
</head>
<body>
<h1>IndexedDB Example</h1>
<p>
@andrewhavens
andrewhavens / sse.rb
Created August 5, 2013 17:25
Working example of SSE using Sinatra and Redis, but with bad concurrency...please help to improve
require 'redis'
require 'sinatra/base'
class SSE < Sinatra::Base
def send_message(json)
"id: #{Time.now}\n" +
"data: #{json}" +
"\r\n\n"
end