Skip to content

Instantly share code, notes, and snippets.

@ogra
ogra / exclude_dropbox_sync.sh
Created December 15, 2021 02:35
Exclude node_modules directory from syncing on Dropbox. (macOS)
#!/bin/bash
EXCLUDEDIR=node_modules
EXLUDEDIR_FULL="`pwd`/$EXCLUDEDIR"
if [[ -d "$EXCLUDEDIR" ]]
then
echo "$EXCLUDEDIR exists on current directory."
else
echo "$EXCLUDEDIR deos not exist on current directory."
@ogra
ogra / blockstack_proof.txt
Created September 30, 2019 22:05
Blockstack proof
Verifying my Blockstack ID is secured with the address 12qNtCZZUWYwUQ5cW37vvJn5Mc6BKsZNqx https://explorer.blockstack.org/address/12qNtCZZUWYwUQ5cW37vvJn5Mc6BKsZNqx
@ogra
ogra / conv_audio_to_video.sh
Last active May 21, 2019 06:55
カレントディレクトリに置いた画像picture.png(ピクセル数は縦横ともに偶数)を使い、カレントディレクトリにあるaudioディレクトリにあるすべてのMP3ファイル(拡張子.mp3)をffmpegで動画に変換して、カレントディレクトリにあるvideoディレクトリにMP4ファイルとして保存するスクリプト
#!/usr/bin/env bash
for filename in ./audio/*.mp3; do
outputfile=`echo $filename | sed 's/^\.\/audio\//\.\/video\//' | sed 's/mp3$/mp4/'`
ffmpeg \
-loop 1 \
-r 30000/1001 \
-i picture.png -i $filename \
-vcodec libx264 \
-acodec aac -strict experimental -ab 320k -ac 2 -ar 44100 \

Keybase proof

I hereby claim:

  • I am ogra on github.
  • I am ogura (https://keybase.io/ogura) on keybase.
  • I have a public key whose fingerprint is 98F5 4678 F8A7 28C2 DB10 BC9F E0CA 6969 198E E985

To claim this, I am signing this object:

@ogra
ogra / articles.server.controller.tests.js
Created September 16, 2016 11:41
"MEAN Web Development" p.267-269 for the latest version of Should.js (Array(), Object() instead of Array, Object)
var app = require('../../server.js'),
request = require('supertest'),
should = require('should'),
mongoose = require('mongoose'),
User = mongoose.model('User'),
Article = mongoose.model('Article');
var user, article;
describe('Articles Controller Unit Tests:', function() {
@ogra
ogra / gist:2204403
Created March 26, 2012 10:46
returns if any elements in example_list are in example_string.
# the following code returns if any elements in example_list are in example_string.
True in [x in example_string for x in example_list]
# example: 'a' is in 'apple', so True is returned.
# >>> example_list = ['a', 'b', 'c']
# >>> example_string = 'apple'
# >>> True in [x in example_string for x in example_list]
# True
@ogra
ogra / FixChartAxes
Created August 9, 2011 12:45
Excel macro to make clustered charts' axes in the book start from zero.
Sub FixChartAxes()
'
' FixChartAxes Macro
'
' Define chart types to process
Dim chart_types As New Collection
With chart_types
.Add Item:=xlBarClustered
.Add Item:=xlColumnClustered
@ogra
ogra / console.py.20110802.diff
Created August 2, 2011 19:28
Scrapy 0.12.0.2543 scrapy/utils/console.py patch for IPython 0.11
--- console.py.orig 2011-07-31 08:01:34.000000000 +0000
+++ console.py 2011-08-02 20:38:56.000000000 +0000
@@ -11,7 +11,10 @@
if noipython:
raise ImportError
import IPython
- shell = IPython.Shell.IPShellEmbed(argv=[], user_ns=namespace)
+ if IPython.__version__ == '0.11':
+ shell = IPython.embed(user_ns=namespace)
+ else:
@ogra
ogra / ukr_pop_pyramid.R
Created March 26, 2011 12:20
Ukraine population pyramid 1985
require(plotrix)
data = read.csv("UNPop_ukraine_age_sex_1985-2010.csv")
data = data[-379, ]
data1 = subset(data, select=c("Sex", "Year", "Age", "Value"))
xy.pop1985 = subset(data1[data1$Sex=="Male" & data1$Year==1985,], select="Value")$Value
xx.pop1985 = subset(data1[data1$Sex=="Female" & data1$Year==1985,], select="Value")$Value
agelabels = unique(subset(data1, select="Age")$Age)
xx.pop1985ratio = xx.pop1985 / sum(xx.pop1985) * 100
xy.pop1985ratio = xy.pop1985 / sum(xy.pop1985) * 100
par(mar=pyramid.plot(xy.pop1985ratio,xx.pop1985ratio,labels=agelabels,main="Ukraine population pyramid 1985",gap=1.5,show.values=TRUE))