Skip to content

Instantly share code, notes, and snippets.

View DeastinY's full-sized avatar
🏠
Working from home

DeastinY DeastinY

🏠
Working from home
View GitHub Profile
//Add OnClickAJAX to Switches
$(".bootstrap-switch").on('switchChange,boostrapSwitch',function(event,state) {
alert("Toggled!");
$.ajax({
url: '/togglelamp',
data: 'TEST',
type: 'POST'
});
});
from flask import Flask, render_template, redirect, request,jsonify
from flask.ext.navigation import Navigation
from lampcontrol import lampcontrol
app = Flask(__name__)
nav = Navigation(app)
# Create Navigation
nav.Bar('top', [
nav.Item('Lamps', 'index'),
from collections import namedtuple
import os
import phue
import json
import logging
Lamp = namedtuple('Lamp', 'name state')
# setup lamps on first startup
bridge = phue.Bridge("192.168.0.10") # TODO: Bad hardcoded string
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server {
listen 80;
listen [::]:80;
return 301 https://blog.$server_name$request_uri;
server_name ars-artificia.com;
root /usr/share/nginx/html;
index index.html index.htm;
upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name cloud.ars-artificia.com;
# enforce https
return 301 https://$server_name$request_uri;
#!/usr/bin/python
# -*- coding: latin-1 -*-
#:kivy 1.9.0
#:import NavigationDrawer kivy.garden.navigationdrawer
#:import RandChar chargen.randchar
<WrapLabel@Label>:
text_size: self.size
<SidePanel@GridLayout>:
ExifTool Version Number : 10.10
File Name : DSC_0040.NEF
Directory : .
File Size : 19 MB
File Modification Date/Time : 2016:06:14 10:32:06+02:00
File Access Date/Time : 2016:06:14 10:32:06+02:00
File Inode Change Date/Time : 2016:06:14 10:32:06+02:00
File Permissions : rwx------
File Type : NEF
File Type Extension : nef
@DeastinY
DeastinY / readfile.py
Created July 29, 2016 08:11
Readline
>>> import json
>>> f = open("somefile.json")
>>> d = json.load(f)
>>> print d
{u'95659045': {u'90': False}}
>>> f.seek(0)
>>> l = f.readlines()
>>> print l
['{"95659045": {"1": false}, "95659045": {"90": false}}']
>>>
@DeastinY
DeastinY / toh_states.py
Created September 23, 2016 09:13
TOH State Generation
def unique(iterable):
# http://stackoverflow.com/questions/6534430/why-does-pythons-itertools-permutations-contain-duplicates-when-the-original
seen = set()
for i in iterable:
if str(i) in seen:
continue
seen.add(str(i))
yield i
states = [i for i in unique(itertools.permutations([[2,1],[],[]]))] + \
...
['like', 'feel', 'girls', 'cause', 'make', 'said', 'shit', 'bitch', 'chorus', 'em']
['que', 'el', 'te', 'yo', 'tu', 'en', 'lo', 'mi', 'se', 'es']
['oh', 'gonna', 'ah', 'uh', 'ooh', 'whoa', 've', 'hands', 'woah', 'beautiful']
['love', 'want', 'heart', 'need', 'real', 'way', 'cause', 'live', 'boy', 'game']
['la', 'el', 'en', 'los', 'ella', 'ooh', 'hey', 'es', 'pa', 'las']
['na', 'music', 'choose', 'cool', 'bump', 'ready', 'hey', 'bad', 'shine', 'shoe']
['don', 'wanna', 'want', 'stop', 'need', 'say', 'cause', 'care', 'think', 'tell']
['yeah', 'hard', 'ah', 'ooh', 'hey', 'right', 'money', 'woah', 'party', 'whoa']
['got', 've', 'money', 'party', 'cause', 'boy', 'em', 'look', 'bitch', 'damn']