Skip to content

Instantly share code, notes, and snippets.

@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")
@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
// 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"`
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
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
@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 (
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:
if (obj.photo){
// console.log(obj);
caches.open(contentImgsCache).then(function(cache){
cache.keys().then(function(requests){
requests.forEach(function(request){
// console.log(obj);
if (obj.photo.split('/').pop() != request.url.split('/').pop()){
cache.delete(request).then(function(result){
if (result === false)
console.log("error deleting : "+request.url);
  • Traditional SQL databases are built from ground up to run on single machine.
  • Inorder to scale them you can only do verticals, ie if you wanna add more power you buy a more powerfull system.
swagger: "2.0"
info:
description: From the todo list tutorial on goswagger.io
title: A Todo list application
version: 1.0.0
consumes:
- application/io.goswagger.examples.todo-list.v1+json
produces:
- application/io.goswagger.examples.todo-list.v1+json
schemes: