Skip to content

Instantly share code, notes, and snippets.

View colonelpanic8's full-sized avatar

Ivan Malison colonelpanic8

View GitHub Profile
@colonelpanic8
colonelpanic8 / gist:5018963
Last active July 6, 2016 18:58
Mapping Letters to the numbers they are associated with on a telephone.
tarting_value = [0, 0] + [3 for i in range(5)] + [4, 3, 4]
partial_sums = [sum(starting_value[:i]) for i in range(len(starting_value)+1)]
letter_to_number = dict(reduce(
lambda x,
y: x+y,
[map(lambda letter: (letter, number), letters) for number, letters in enumerate(map(lambda a_list: map(lambda char: chr(char+65), a_list), [range(*value) for value in zip(partial_sums[:-1], partial_sums[1:])]))]
))
We couldn’t find that file to show.
@colonelpanic8
colonelpanic8 / 0_reuse_code.js
Created August 14, 2014 18:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
from okcupyd import User
def stuff():
user = User()
profiles = user.search()
for profile in profiles[:1]:
for q in profile.questions[:10]:
# encoding data to utf8
(defun get-ensime-type-info-from-mark ()
(interactive)
(message "%s" (ensime-rpc-inspect-type-at-range (get-eol-range))))
(defun get-eol-range ()
(interactive)
`(,(marker-position (point-marker))
,(save-excursion (end-of-line) (point))))
import requests
import subprocess
from lxml import html
from xpath import xpb
def get_stdout_from_command(command, args):
return subprocess.Popen(command, stdout=subprocess.PIPE).stdout.read()
[user]
name = Ivan Malison
email = [email protected]
def rotate_array(incoming, rotation_index):
new_back = incoming[:rotation_index]
new_front = incoming[rotation_index:]
new_front.extend(new_back)
return new_front
def binary_search(
array, item, low=0, high=None,
lower_predicate=lambda item, array, index, low, high: item <= array[index]
<!DOCTYPE html>
<html>
<head>
<title>Manifold</title>
</head>
<body>
<%= render "layouts/errors" %>
<% if logged_in? %>
<%= current_user.email %>
<%= button_to "Sign Out", session_url, method: :delete %>
(defun github-clone-get-repo-name-from-remote (&optional remote)
(unless remote
(setq remote
(magit-read-remote "Select a remote: ")))
(github-clone-repo-name
(magit-get "remote" remote "url")))
(defun github-clone-fork-remote (&optional remote)
(interactive (list (magit-read-remote "Select a remote")))
(cl-destructuring-bind (user . repo)