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
# crontab format | |
# * * * * * command to be execute | |
# | | | | +---- day of week (0 - 6) (Sunday = 0 or 7) or sun, mon, ..., sat | |
# | | | +------ month (1 - 12) or jan, feb, ..., dec | |
# | | +-------- day of month (1 - 31) | |
# | +---------- hour (0 - 23) | |
# +------------ minute (0 - 59) | |
# special string | |
# string meaning | |
# ------ ------- |
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 | |
# -*- coding: utf-8 -*- | |
# bookmark script for newsbeuter | |
# by Akihiro Uchida, CC0 dedicated to the public domain | |
# see http://creativecommons.org/publicdomain/zero/1.0/ | |
import sys | |
import os.path | |
import cPickle as pickle | |
BOOKMARK = os.path.expanduser('~/newsbeuter/bookmark.pkl') |
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
#!/bin/sh | |
osascript -e "tell application \"Safari\" | |
tell window 1 | |
set current tab to (make new tab) | |
set currenttab to open location \"$@\" | |
end tell | |
end tell" |
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 functools, operator | |
prod = functools.partial(functools.reduce, operator.mul) | |
def ndindex(maxvals): | |
total = prod(maxvals) | |
index = [0] * len(maxvals) | |
for _ in range(total): | |
yield tuple(index) | |
for i, n in enumerate(reversed(maxvals)): | |
index[-i-1] += 1 | |
if index[-i-1] < n: |
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:utf8 -*- | |
# Tokyo.Scipy#2 ディスカッション事前アンケート | |
# http://www.surveymonkey.com/s/XJ2KNBW | |
# | |
# 3. nanやInfを含む値の列 | |
# x = numpy.array([[1,0,nan,1,Inf,1,....]]) | |
# が与えられたとき、 | |
# NaNやInf以外のxの要素の合計を計算する方法が直ぐに思い浮かびますか? | |
from numpy import array |
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:utf8 -*- | |
# Tokyo.Scipy#2 ディスカッション事前アンケート | |
# http://www.surveymonkey.com/s/XJ2KNBW | |
# | |
# 4. nanを含む4x2行列 | |
# m = numpy.array([[1,nan,-1,0],[0,0,nan,1]]) | |
# が与えられたとき、 | |
# nanを含む行を削除して2x2行列にする方法が直ぐに思い浮かびますか? | |
from numpy import array |
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:utf8 -*- | |
# Tokyo.Scipy#2 ディスカッション事前アンケート | |
# http://www.surveymonkey.com/s/XJ2KNBW | |
# | |
# 5. numpy.array([[1,3,2]]) を、1-of-K表記法変換して | |
# numpy.array([[1,0,0],[0,0,1],[0,1,0]]) | |
# にする処理方法が直ぐに思い浮かびますか? | |
from numpy import array, zeros |
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
// GWLlosa's answer in http://stackoverflow.com/questions/521687/c-sharp-foreach-with-index | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace EnumerateTest { | |
class Program { | |
static void Main(string[] args) { | |
List<int> list = new List<int> {4, 2, 3, 1, 8}; |
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
// Guffa's answer in http://stackoverflow.com/questions/659866/is-there-c-sharp-support-for-an-index-based-sort | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace IndexSortTest { | |
class Program { | |
static void Main(string[] args) { | |
List<int> list = new List<int> {4, 2, 3, 1, 8}; | |
int N = list.Count; |
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
// the Fisher–Yates shuffle algorithm | |
// see http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ShuffleTest { | |
class Program { | |
static void Main(string[] args) { | |
List<int> shuffled = ShuffleRange(0, 10).ToList<int>(); |
OlderNewer