Skip to content

Instantly share code, notes, and snippets.

import idb from 'idb';
var dbPromise = idb.open('test-db', 4, function(upgradeDb) {
switch(upgradeDb.oldVersion) {
case 0:
var keyValStore = upgradeDb.createObjectStore('keyval');
keyValStore.put("world", "hello");
case 1:
upgradeDb.createObjectStore('people', { keyPath: 'name' });
case 2:
@scriptonist
scriptonist / jwt-example.go
Created November 23, 2017 16:22
JsonWebTokens Example with generated key.
/* rewritten example of JsonWebToken example
* from https://gist.github.com/thealexcons/4ecc09d50e6b9b3ff4e2408e910beb22
* Keys are generated and packed to PEM-format at server start
* Plus some fixes and refactors
*
* My respect to thealexcons
*/
package main
import (
package main
import "fmt"
import "sort"
func main() {
var n,m int
fmt.Scanf("%d%d",&n,&m)
ar := make([]int,m,m)
for i:=0;i<m;i++{
var a,b,k int
source=$1
dest=$2
if [ ! -f $dest ]; then
echo "File does not exist, now copying.."
cp -fr "$source" "$dest"
elif [ "$source" -nt "$dest" ]
then
echo "Newer version found, copying the newer version.."
cp -fr "$source" "$dest"
else
// ErrorStruct response returned by gitub API
type ErrorStruct struct {
Message string `json:"message"`
DocumentationURL string `json:"documentation_url"`
Error []map[string]string `json:"errors,omitempty"`
}
type successStruct struct {
ID int `json:"id"`
URL string `json:"url"`
@scriptonist
scriptonist / tmux-cheatsheet.markdown
Created August 11, 2017 04:41 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@scriptonist
scriptonist / sr.py
Created April 15, 2017 10:41
SerializerV1
class HrProfileSerializer(serializers.ModelSerializer):
company = serializers.RelatedField(read_only=True)
username = serializers.CharField(source='user.username', read_only=True)
email = serializers.CharField(source='user.email')
password = serializers.CharField(source='user.password')
#groups = serializers.CharField(source='user.password')
class Meta:
model = HrProfile
fields = ("username", "email", "password", "company")