This file contains hidden or 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
if ( $(window).width() <= 720 ) { | |
var _card = $('.product-grid-item'); | |
var cardLen = _card.length; | |
var cardHeight = _card.height(); | |
var totalCardHeight = cardLen * cardHeight; | |
$('#results-container').css('min-height', (totalCardHeight+cardHeight) +'px'); | |
} |
This file contains hidden or 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
extension String { | |
/// Truncates the string to length number of characters and | |
/// appends optional trailing string if longer | |
func truncate(length: Int, trailing: String? = nil) -> String { | |
if countElements(self) > length { | |
return self.substringToIndex(advance(self.startIndex, length)) + (trailing ?? "") | |
} else { | |
return self | |
} | |
} |
This file contains hidden or 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 csv_to_js_array(csv_path): | |
import csv | |
import os | |
attributes = [] | |
values = [] | |
with open(csv_path, "rb") as csvfile: | |
print csvfile |
This file contains hidden or 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 underscore_to_camel_case(string): | |
return ''.join([chunk.capitalize() for chunk in string.split("_")]) |
This file contains hidden or 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 copy_row(model, row, ignored_columns=[]): | |
copy = model() | |
for col in row.__table__.columns: | |
if col.name not in ignored_columns: | |
try: | |
copy.__setattr__(col.name, getattr(row, col.name)) | |
except Exception as e: | |
print e | |
continue |
This file contains hidden or 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
<style> | |
/* Diamond Hack CSS */ | |
.diamond { | |
width: 160px; | |
height: 160px; | |
-ms-transform: rotate(-45deg); | |
-webkit-transform: rotate(-45deg); | |
transform: rotate(-45deg); |
This file contains hidden or 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
# Allows for any file to be extracted using: x $1 | |
x () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) rar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xvf $1 ;; |
This file contains hidden or 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 socket import socket, SO_REUSEADDR, SOL_SOCKET | |
from asyncio import Task, coroutine, get_event_loop | |
class Peer(object): | |
def __init__(self, server, sock, name): | |
self.loop = server.loop | |
self.name = name | |
self._sock = sock | |
self._server = server | |
Task(self._peer_handler()) |
This file contains hidden or 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
# gif-maker.py | |
# Copyright 2013 Kendrick Ledet | |
import sys, os | |
path = sys.argv[1] | |
start = sys.argv[2] | |
end = sys.argv[3] | |
fname = os.path.basename(path) | |
print fname |
This file contains hidden or 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
import urllib2, re, random | |
html = urllib2.urlopen('https://pypi.python.org/pypi?%3Aaction=index').read() | |
r = re.compile(r'/pypi/([-A-Za-z0-9\.]+)/([-A-Za-z0-9\.]+)') | |
pkgName, pkgVersion = random.choice(re.findall(r, html)) | |
print 'Found random package {} {}, located at https://pypi.python.org/pypi/{}/{}'.format(pkgName, pkgVersion, pkgName, pkgVersion) |
NewerOlder