Skip to content

Instantly share code, notes, and snippets.

View liavkoren's full-sized avatar

Liav liavkoren

View GitHub Profile
@liavkoren
liavkoren / gist:9053b059fb8578a58e26
Created December 1, 2014 18:36
jQuery code which runs twice
$( document ).ready(function() {
var replace_text_element_with_provinces = function(text_element) {
/*
Accepts a reference to a form's text element, builds a select
element populated with Canadian provinces and replaces the text
element with the select element.
*/
var provinces = $("#id_country").data("provinces");
# A dictionary comprehension:
a = {num: Node(num) for num in range(1, 8)}
```
a now looks like:
{1: Node(data=1, next_node=None),
2: Node(data=2, next_node=None),
3: Node(data=3, next_node=None),
4: Node(data=4, next_node=None),
5: Node(data=5, next_node=None),
#!/usr/bin/python
import fileinput
def data_stream():
for line in fileinput.input():
line = line.strip()
yield line
"""
https://www.hackerrank.com/challenges/luck-balance
[(6, 3), (5, 1), (2, 1), (1, 1), (8, 1), (10, 0), (5, 0),]
"""
import fileinput
def data_stream():
import fileinput
import sys
sys.setrecursionlimit(10000)
def solve(houses, transmitter_range):
houses.sort(reverse=True)
if len(houses) == 0:
return 0
Path /Users/liavkoren/.config/powerline/colorschemes/solarized.json.old is not a directory or configuration file
Path /Users/liavkoren/.config/powerline/colorschemes/vim/solarized.json.old is not a configuration file
Path /Users/liavkoren/.config/powerline/colorschemes/vim/solarizedlight.json.old is not a configuration file
One of the either variants failed. Messages from the first variant:
Error while loading groups (key /groups/email_alert)
ImportError Traceback (most recent call last)
<ipython-input-1-e19bbed7988a> in <module>()
----> 1 import ipytracer
2 from IPython.core.display import display
3
4 def bubble_sort(unsorted_list):
5 x = ipytracer.ChartTracer(unsorted_list)
/Users/liavkoren/Envs/coding-university/lib/python3.6/site-packages/ipytracer/__init__.py in <module>()
14 """
from enum import Enum
import attr
from attr.validators import instance_of
@attr.s
class EdgeNode:
"""
An Edge & a Node.
@liavkoren
liavkoren / site.py
Created July 6, 2017 18:45
Incorrectly calculating bounce rates
from collections import defaultdict
initial_pages = defaultdict(lambda: 0)
bounce_rates = defaultdict(lambda: 0)
for line in open('site_data.csv'):
first, second = line.rstrip().split(',')
if first == '-1':
initial_pages[second] += 1
@liavkoren
liavkoren / int2word.py
Created August 14, 2017 18:50
work around paypal's self-defeating security feature
lookup = {
'1': 'one',
'2': 'two',
'3': 'three',
'4': 'four',
'5': 'five',
'6': 'six',
'7': 'seven',
'8': 'eight',
'9': 'nine',