This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rule1 = | |
[["Z"; "d"]; ["Z"; "X"; "Y"; "Z"]; ["Y"]; ["Y"; "c"]; ["X"; "Y"]; ["X"; "a"]] | |
let rule2 = | |
[ ["S'"; "L"; "$"] | |
; ["L"; "S"; ";"; "L"] | |
; ["L"; "S"] | |
; ["S"; "id"; "="; "E"] | |
; ["S"; "print"; "("; "E"; ")"] | |
; ["E"; "T"; "E'"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// MAKE MAGAZINE - LASER HARP FOR ARDUINO | |
// Stephen Hobley 2008 | |
// www.stephenhobley.com | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// Variables: /////////////////////////////////////////////////////////////////////////////////////////// | |
#define BEAMCOUNT 6 // レーザーの数 | |
#define MIDICMD_NOTEON 0x90 // MIDIコマンド (Note On, Channel 0) | |
#define MIDICMD_CTRL 0xb0 // MIDI Controller message - channel 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
client_max_body_size 20M; | |
server_name {{ domain }}; | |
location /.well-known/acme-challenge/ { | |
alias /var/www/letsencrypt/.well-known/acme-challenge/; | |
try_files $uri =404; | |
access_log off; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"fmt" | |
"net/mail" | |
"net/smtp" | |
"github.com/scorredoira/email" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from http://lua-users.org/wiki/TableSerialization | |
function print_r (t, name, indent) | |
local tableList = {} | |
function table_r (t, name, indent, full) | |
local serial=string.len(full) == 0 and name | |
or type(name)~="number" and '["'..tostring(name)..'"]' or '['..name..']' | |
io.write(indent,serial,' = ') | |
if type(t) == "table" then | |
if tableList[t] ~= nil then io.write('{}; -- ',tableList[t],' (self reference)\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def call_classmethod(*args): | |
""" | |
モジュール内のクラスのクラスメソッドを実行しやすくするためのヘルパ関数 | |
args にはメソッドを実行したいclassを指定 | |
""" | |
current_module = sys.modules[__name__] | |
factories = {} | |
results = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class test(object): | |
"""A property whose value is computed only once. """ | |
def __init__(self, function): | |
self._function = function | |
def __get__(self, obj, _=None): | |
if obj is None: | |
return self | |
value = self._function(obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
def divide(num, by): | |
""" num を バランスよく by分割する関数 | |
e,g:num=13, by=2 => [7, 6] | |
num=30, by=4 => [8, 8, 7, 7] | |
""" | |
quotient, rest = divmod(num, by) | |
ans = [quotient for i in range(by)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dump_queryset(qs, format='yaml', indent=2, filename=None): | |
""" QuerySet をカレントディレクトリにyamlで出力するCLI Utility """ | |
if not isinstance(qs, QuerySet): | |
raise ValueError(u'QuerySet以外はシリアライズできません') | |
data = serializers.serialize(format, qs, indent=indent) | |
if not filename: | |
model_name = qs[0].__class__.__name__ | |
now_str = datetime.now().strftime('%Y_%M_%d__%H_%M_%S') |
NewerOlder