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
while (!(response=cdoi.receiveMessageFromServer()).equals (new String ())) System.out.println(response); |
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 merge_lists_into_string(a, b, string): | |
''' | |
Takes two lists of varying size and merges them like so: | |
([1,2,3], [10, 20, 30, 40, 50]) >> [1, 10, 2, 20, 3, 30, 40, 50] | |
''' | |
if a: | |
string += a.pop(0) | |
if b: | |
string += b.pop(0) | |
if a or b: |
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
" Add this to your vimrc | |
" New mappings: c | |
" h t n | |
" This also integrates this mapping into insert mode via <Alt> | |
"Navigation for dvorak |
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
; Requires this event handler | |
(reg-event-db :db-swap | |
(fn [db [_ func value]] | |
(func db value))) | |
;The go-swap effect | |
(reg-fx :go-swap |
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 my_map(fn, coll): | |
reduce(lambda out, x: out + [fn(x)], coll, []) |
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 my_filter(fn, coll): | |
reduce(lambda out, x: out + ([x] if fn(x) else []), coll, []) |
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 thread_first(value, *forms): | |
''' | |
Returns the given value threaded through the given collection of forms as the first argument. | |
A form is a function or a tuple containing a function as its first element and a list of arguments. | |
The return value of the previously called function will be threaded in as the first argument to the next function. | |
Use this to flatten nested function calls. | |
Example: | |
>>> def add(a, b): |
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 equals(value): | |
''' | |
Returns a function that when called will check the called value with the given value for equality | |
''' | |
return lambda called_value: value == called_value | |
def reverse(collection): | |
return collection[::-1] | |
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
#!/usr/bin/env python | |
""" | |
Restart router when it goes offline | |
Runs on orange pi zero v1 | |
""" | |
import os | |
import sys | |
if not os.getegid() == 0: |
OlderNewer