Skip to content

Instantly share code, notes, and snippets.

View furushchev's full-sized avatar
🤖

Yuki Furuta furushchev

🤖
View GitHub Profile
@furushchev
furushchev / euler-12-slow.lisp
Created June 4, 2013 16:07
Project Euler Problem12 Too slow T_T
(defun sum-n (n)
(if (= n 1)
1
(+ n (sum (- n 1)))))
(defun check-div (num)
(labels ((check-div-r (n k)
(if (= k 1)
1
(if (integerp (/ n k))
@furushchev
furushchev / euler-12-fast.lisp
Created June 4, 2013 16:09
Project Euler Problem12 Fast
(defun sum-n (n)
"(+ 1 2 3 ... n)"
(* n (1+ n) 1/2))
(defun check-div (num)
"return number of factors of num"
(labels ((check-div-r (n k)
(if (= k 1)
1
(if (integerp (/ n k))
@furushchev
furushchev / euler_12.py
Created June 4, 2013 16:10
Project Euler Problem 12
#!/usr/bin/env python
import math as m
def check_div(num):
ret = 0
sq = m.sqrt(num)
for i in range(1, int(round(sq))+1):
if num % i == 0:
ret += 1
@furushchev
furushchev / notify_after_rosmake.bash
Last active December 26, 2015 14:59
長すぎるrosmakeの途中にし始めた他の作業に没頭してrosmakeしていたことを忘れてしまう全ての人へ
cat << \__EOF__ >> ~/.bashrc
# notify when rosmake finished
# from https://gist.github.com/furushchev/7170086/
alias alert_helper='history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"'
alias alert='notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "[$?] $(alert_helper) finished."'
function rosmake(){
function napr(){
local FROM TO
if [ $# -eq 1 ]; then
FROM="ru"; TO="ja"
elif [ $# -eq 3 ]; then
FROM=$2; TO=$3
else
echo -e "[usage] napr phrase [from(ru) to(ja)]\n To end press 'q'" 1>&2
echo -e "e.g\n napr например ru ja\n napr 例 ja ru" 1>&2
fi
@furushchev
furushchev / alert_after_long_command.bash
Created May 28, 2014 12:52
時間のかかるコマンドの後に知らせてくれるコマンド
#!/bin/bash
cat <<EOF >> ~/.bashrc
function alert(){
local SAY="say -v Otoya" # use "say -v Kyoko" if you like female
if [ \$# -ge 1 ]; then
\$@ && \$SAY "\$@ が おわったでー。"
else
\$SAY "なにすんねん!"
@furushchev
furushchev / update-dens.sh
Created September 28, 2014 00:12
Update No-ip DDNS
#!/bin/bash
if [ "$1" = "" ]; then
GLOBAL_IP=`curl -s ifconfig.me`
else
GLOBAL_IP=$1
fi
USERNAME=username
PASSWORD=password
HOSTNAME=hostname
@furushchev
furushchev / ors-package-reverter.sh
Created November 7, 2014 08:07
ROS Package Reverter
#!/bin/bash
function abort() {
echo "error: $1"
echo "abort..."
exit 1
}
# find ws root
PKGPATHS=`rospack list | grep src`
@furushchev
furushchev / pr2_interface.png
Last active August 29, 2015 14:13
preemptive-task-execution
pr2_interface.png
@furushchev
furushchev / dump-function-and-args.l
Last active August 29, 2015 14:13
dump function and args in euslisp
#!/usr/bin/env roseus
(setq *l* nil)
#|
(defun fuga (cds)
(print "called fuga")
(print cds)
(print *l*)
(push (list #'fuga cds) *l*) ;; applyしたときにここでとまってしまう
(print *l*)