Skip to content

Instantly share code, notes, and snippets.

@narrowlyapplicable
narrowlyapplicable / ts-test.ipynb
Last active March 3, 2020 15:24
StatModeling Memorandumの記事「二つの時系列データの間に「差」があるか判断するには」 <http://statmodeling.hatenablog.com/entry/difference-between-time-courses> をpystanに置き換えて実装
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ysaotome
ysaotome / install_pyenv.sh
Last active August 7, 2021 13:27
pyenv install for CentOS 6.5 x86_64
#!/bin/zsh
# pyenv install for CentOS 6.5 x86_64
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
@keichan34
keichan34 / active_record_marshalable.rb
Created September 5, 2013 11:33
Get Marshal.dump and Marshal.load to load cached association objects ( Whatever.includes(:example_models) ), as well.
module ActiveRecordMarshalable
def marshal_dump
[attributes, self.association_cache, instance_variable_get(:@new_record)]
end
def marshal_load data
send :initialize, data[0]
instance_variable_set :@association_cache, data[1]
instance_variable_set :@new_record, data[2]
end
@wkrsz
wkrsz / devise.rb
Created January 9, 2013 11:48
Support for token HTTP header authentication in Devise
#config/initializers/devise.rb
config.warden do |manager|
manager.strategies.add :token_header_authenticable, TokenHeaderAuthenticable
manager.default_strategies(:scope => :user).unshift :token_header_authenticable
end
@jinze
jinze / forever-initd-example.sh
Created September 19, 2012 09:50
forever init.d example
#!/bin/bash
#
# initd-example Node init.d
#
# chkconfig: 345 80 20
# description: Node init.d example
# processname: node
# pidfile: /var/run/initd-example.pid
# logfile: /var/log/initd-example.log
#
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 7, 2024 15:24
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active December 26, 2022 19:30
Nginx + secure pseudo-streaming
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
cd /usr/src
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz
@pda
pda / unicorn.rake
Created September 12, 2011 07:39
Rake tasks for Unicorn: start stop restart increment decrement pstree
namespace :unicorn do
##
# Tasks
desc "Start unicorn"
task(:start) {
config = rails_root + "config/unicorn.rb"
sh "bundle exec unicorn --daemonize --config-file #{config}"
}