Skip to content

Instantly share code, notes, and snippets.

View jancajthaml's full-sized avatar
🦈

Jan Cajthaml jancajthaml

🦈
View GitHub Profile
#############################################
# Info backend requirements:
# - device token hash saved in database
# - number of unred notifications for token hash
# - Apple Certification File
# - SSL Key
#
# Info communication requirements:
# - what kind of notification
# - json data
# Quick and Dirty DRAFT for Google Cloud Messaging REST by Petnik
import random
import requests
import json
api_key = 'XXXXXXXxXXXXXXXxXXXXXXXxXXXXXXXx'
gateway = 'https://android.googleapis.com/gcm/send'
##################
@jancajthaml
jancajthaml / gist:0c6ec60a093f24fc932c
Created July 29, 2014 15:34
Binary Data + JSON data in pure Websocket (JavaScript)
<html>
<body>
<script>
var canvas = document.createElement("canvas")
var context = canvas.getContext("2d");
var connection = new WebSocket('XXXXX');
connection.binaryType = "arraybuffer";
#723610554
self="$(pwd)/$(basename "$0")"
checksum="$(cat "$self" | awk '{if(NR>1)print}' | cksum | awk '{ print $1 }')"
sed "1s/.*/#$checksum/" $self > "$self.bak"
rm $self
mv "$self.bak" $self
#! /usr/bin/env python
import sys
import signal
import os
import fcntl
import termios
import struct
block = os.O_NONBLOCK if 'O_NONBLOCK' in dir(os) else (
os.NOBLOCK if 'NONBLOCK' in dir(os) else None)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import signal
import os
import fcntl
import termios
import struct
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import signal
import os
import fcntl
import termios
import struct
import itertools
@jancajthaml
jancajthaml / google one time password
Last active April 24, 2016 23:37
python equivalent to "oathtool --totp -b $key" usage "python script.py $key"
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import time
import struct
import hashlib
import binascii
@jancajthaml
jancajthaml / profiles.stat
Created April 25, 2016 05:50
why shouldn't you trust legacy native code
# determining native complexity
5091 function calls (4927 primitive calls) in 0.009 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
2 0.000 0.000 0.000 0.000 UserDict.py:18(__getitem__)
11 0.000 0.000 0.000 0.000 UserDict.py:58(get)
13 0.000 0.000 0.000 0.000 UserDict.py:70(__contains__)
function exists(e) {
return {
[false]: false,
[void 0]: true
}[{
[void 0]: false,
[{}]: false,
[false]: false,
[undefined]: false,
[1 / 0]: false