Skip to content

Instantly share code, notes, and snippets.

''=~( '(?{' .('`' |'%') .('[' ^'-')
.('`' |'!') .('`' |',') .'"'. '\\$'
.'==' .('[' ^'+') .('`' |'/') .('['
^'+') .'||' .(';' &'=') .(';' &'=')
.';-' .'-'. '\\$' .'=;' .('[' ^'(')
.('[' ^'.') .('`' |'"') .('!' ^'+')
.'_\\{' .'(\\$' .';=('. '\\$=|' ."\|".( '`'^'.'
).(('`')| '/').').' .'\\"'.+( '{'^'['). ('`'|'"') .('`'|'/'
).('['^'/') .('['^'/'). ('`'|',').( '`'|('%')). '\\".\\"'.( '['^('(')).
'\\"'.('['^ '#').'!!--' .'\\$=.\\"' .('{'^'['). ('`'|'/').( '`'|"\&").(
@Deiru2k
Deiru2k / gulpfile.js
Created September 4, 2014 15:50
Gulpfile
/*
gulp clean && gulp build && gulp templates
OH GOD WHY SO JAVASCRIPT
*/
"use strict"
var gulp = require("gulp"),
$ = require("gulp-load-plugins")();
@Deiru2k
Deiru2k / app.py
Last active August 29, 2015 14:08
Using RethinkDB with tornado
from tornado.gen import coroutine
from tornado.web import RequestHandler
from tornado.web import Application
from tornado.ioloop import IOLoop
import rethinkdb.net as net
import rethinkdb as r
connection = r.connect(host='localhost')
@Deiru2k
Deiru2k / dict_to_xml.py
Last active November 23, 2015 14:42
Dict To Xml
from xml.etree import ElementTree as et
from xml.dom import minidom
"""
Convert Python dict to XML using a special set of rules
Function build_xml takes a specialy formatted dict and returns xml.etree.ElementTree Element.
1) There can be only one Root Element, it must be at a top-level of a dictionary and it should be the only element at
top-level
2) Keys are element names, key values should be dicts with element params.
3) If there should be more than one elements with the same name, key value could be a list of dicts with params.
@Deiru2k
Deiru2k / spanish_inquisition.py
Created February 12, 2015 11:05
How I deal with exceptions and how I'm /supposed/ to deal with them. Should I continue, or is it a bad practice?
# Case One: How /it should be/ done:
class CloudStorageRaises(object):
def upload_picture(file):
try:
url = self.storageApi.upload_from_file(file).generate_url()
return url
except Exception as e:
@Deiru2k
Deiru2k / proschema.py
Last active August 29, 2015 14:16
Of Projections and schemas
{
"type": "object",
"properties": {
"mainPhoto": {"type": "string"},
"propertyType": {"type": "string"},
"price": {
"type": "object",
"properties": {
"USD": {"type": "number"},
"RUB": {"type": "number"}
@Deiru2k
Deiru2k / kostyl.py
Created March 12, 2015 16:17
KOSTYL
if object_['landProperties']:
if object_['landProperties']['landscapeType']:
if 'landtype' in object_['landProperties']['landscapeType']:
if object_['landProperties']['landscapeType']['landtype']:
if isinstance(object_['landProperties']['landscapeType']['landtype'], str):
object_['landProperties']['landscapeType']['landtype'] = \
object_['landProperties']['landscapeType']['landtype'].split(',')
object_['landProperties']['landscapeType'] = ", ".join([
self.dictionary['land_type'][land_type].lower()
for land_type in object_['landProperties']['landscapeType']['landtype']
@Deiru2k
Deiru2k / auth.js
Created September 24, 2015 09:05
SUPER AUTH
auth.singInWebapi = (user) => {
return new $q((resolve, reject) => {
const address = `${$API.url}Token`;
const request = new XMLHttpRequest;
const handleResponse = () => {
const { status } = request;
if (request.readyState === request.DONE) {
if (status > 0) {
const body = JSON.parse(request.response);
@Deiru2k
Deiru2k / spooks.js
Created October 9, 2015 09:31
2Spooky4Me
// App Run
$API.setHeader(`Content-Type`, `application/json`);
// Take One
const headers = new Map();
headers[`Content-Type`] = `multipart/form-data`;
console.log(headers)
// Map{} Content-Type: `multipart/form-data`;
$API.post('UploadAvatar', formData, {headers});
// Request Header: Content-Type: application/json;
@Deiru2k
Deiru2k / site.conf
Created November 22, 2015 18:41
NGINX SPA
server {
listen 80;
root "/var/www/dev.kancolle.io/dist";
server_name "dev.kancolle.io";
location / {
try_files $uri /index.html;
}
}