Skip to content

Instantly share code, notes, and snippets.

@n9986
n9986 / gist:036fa8fc570b18bcddb4ce589387e117
Created November 8, 2016 09:42
Libraries and links for animation and inspiration
Ani
Culebra
point2line
Geomerative
ComputationalGeometry
ToxicLibs
Metamorphosis https://vimeo.com/1747316 (http://www.butterfly.ie/)
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@n9986
n9986 / KeyToolUsage.md
Created April 24, 2016 17:20
Some steps for using KeyTool to generate a key + csr + cer files

Some steps for using KeyTool

keytool -keystore keystore -genkey -alias private -keyalg RSA

keytool -keystore keystore -certreq -alias private -keyalg rsa -file client.csr

keytool -import -keystore keystore -file ca.pem  -alias ca 

# And after signing the certificate request

keytool -import -keystore keystore -file client.cer -alias public

@n9986
n9986 / Bitwise.md
Last active February 17, 2016 16:19
A treatise on Bit based permissions in a database

so there are three tables:

hotel:

  • hotel_id

user:

  • user_id
$scope.changeFontSize = function(delta) {
console.log("fffffff", $scope.settings.fontSize, delta);
$scope.settings.fontSize = parseInt($scope.settings.fontSize) + delta;
$scope.settings.fontSize += "px";
console.log("fffffff", $scope.settings.fontSize, delta);
$(".default").css('fontSize', $scope.settings.fontSize);
};
$scope.settings = {
show: false,
fontSize: parseInt($(".default").css('fontSize'))
@n9986
n9986 / argSlice.js
Created January 30, 2014 07:46
A good way to slice arguments passed to a method and make them array like
var args = Array.prototype.slice.call(arguments);
args.splice(0, 1);
@n9986
n9986 / notSoCircular.js
Created January 1, 2014 17:06
A possible way to prevent circular references in Javascript using closure.
function A(b) {
this.notSoFunky = 100;
this.setB(b);
}
A.prototype = {
setB: function(b) {
this.B = function() {
return b;
};
@n9986
n9986 / ip_port_lol.py
Created December 27, 2013 14:37
Validate IP:PORT
import re
b = '123.0.1.00:1212'
naiveip_re = re.compile(r"""^(?:
(?P<addr>
(?P<ipv4>\d{1,3}(?:\.\d{1,3}){3}) | # IPv4 address
(?P<ipv6>\[[a-fA-F0-9:]+\]) | # IPv6 address
(?P<fqdn>[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*) # FQDN
@n9986
n9986 / factorysample.py
Created March 14, 2013 13:12
Python simple factory style
class MultipleChoice():
name = "multiplechoice"
class QuestionBuilderFactory():
classes = {}
def register(self, cls):
# print getattr(cls, name)
print cls.name
self.classes[cls.name] = cls
@app.route('/upload/foo', methods=['POST'])
@roles_required('admin')
def upload_image():
image_name = request.args['qqfile']
product_image_path = os.path.join(app_config('IMG_PATH'), image_name)
product_thumbnail_path = os.path.join(app_config('THUMB_PATH'), image_name)
with open(product_image_path, 'w') as fh:
fh.write(flask.request.stream.read())