Navigation Menu

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);
@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"] });
@bpesquet
bpesquet / rpg_oloo.js
Created September 20, 2015 17:22
Minimalist RPG exemple written in the OLOO style
var Character = {};
Character.initCharacter = function (name, health, strength) {
this.name = name;
this.health = health;
this.strength = strength;
};
Character.attack = function (target) {
if (this.health > 0) {
var damage = this.strength;
console.log(this.name + " attacks " + target.name + " and deals " + damage + " damage");
@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"});
@adnaan
adnaan / script.sh
Last active September 25, 2019 13:02
Parse and execute a simple bash script.
ls -la
echo "hello"
tree
adb devices
adb wait-for-device #example of a long running task
@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)
})
@ericchiang
ericchiang / flock.go
Last active September 19, 2023 20:26
Golang Flock
package main
// #include <sys/file.h>
import "C"
import (
"fmt"
"os"
"os/exec"
)
@wancw
wancw / y-combinator.go
Last active September 19, 2023 20:22
Y combinator in Go, runable example: http://play.golang.org/p/xVHw0zoaWX
package main
import "fmt"
type (
tF func(int) int
tRF func(tF) tF
tX func(tX) tF
)
@hvasconcelos
hvasconcelos / gen_keys.sh
Last active September 19, 2023 23:14
Create an Sinatra SSL Server
# Generate a self-signed Certificate and a Private Key
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout pkey.pem -out cert.crt
@oderwat
oderwat / gist:9158840
Created February 22, 2014 17:45
GoLang HTTP PUT / DELETE (just copied from somewhere else!)
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
const (