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
extension String { | |
subscript(range:Range<Int>) -> String { | |
return self[advance(self.startIndex, range.startIndex)..advance(self.startIndex, range.endIndex)] | |
} | |
} | |
var s = "abcdefghij" | |
s[1..4] // print "bcd" | |
s[1...4] // print "bcde" |
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
<?php | |
class ThumbnailUtility { | |
const TYPE_KEEP_RATIO = 0; | |
const TYPE_TRIM = 1; | |
public static function Resize( | |
$file_path_or_url, | |
$thumbnail_width = null, |
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 -*- | |
""" | |
File Name: upload_s3.py | |
Usage: python upload_s3.py | |
""" | |
import sys | |
import os | |
import os.path | |
import fnmatch |
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
<?php | |
class InstagramOAuth { | |
const CLIENT_ID = Configuration::INSTAGRAM_CLIENT_ID; | |
const CLIENT_SECRET = Configuration::INSTAGRAM_CLIENT_SECRET; | |
const CALLBACK_URL = Configuration::INSTAGRAM_CALLBACK_URL; | |
public static function getAuthorizationURL($state = null, $scope = InstagramScope::BASIC, $is_implicit_authentication = false) { | |
$scope = $scope == null ? InstagramScope::BASIC : $scope; | |
$response_type = !$is_implicit_authentication ? 'code' : 'token'; |
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
javascript: $(".ProfileCard-avatarImage").each(function() { $avatarImg = $(this); $avatarImg.attr("src", $avatarImg.attr("src").replace("_bigger", "_400x400")); }); |
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
user www; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; |
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
description "[APP NAME] API Server" | |
start on runlevel [2345] | |
stop on runlevel [016] | |
respawn | |
script | |
su - www | |
source /home/www/[APP NAME]/virtualenv/bin/activate |
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
ko.bindingHandlers.dropzone = | |
init: (element, value_accessor) -> | |
passed_value = ko.unwrap value_accessor() | |
send_data = passed_value.data | |
$target = $(element).dropzone | |
url: passed_value.url | |
sending: (file, xhr, form_data) -> | |
for name, value of send_data | |
if typeof(value) == "function" | |
form_data.append name, value() |
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 override_print(message, line_length = 100): | |
if len(message) > line_length: | |
message = message[:line_length - 3] + "..." | |
sys.stdout.write((u"\r{0:<" + str(line_length) + "}").format(message)) | |
sys.stdout.flush() |
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
import xlrd | |
from collections import OrderedDict | |
import simplejson as json | |
excel_path = raw_input('input path> ') | |
json_path = raw_input('output json path> ') | |
wb = xlrd.open_workbook(excel_path) | |
sheets = OrderedDict() |
OlderNewer