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
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Synchronous (blocking) | |
# Returns the output of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
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
function [maxtab, mintab]=peakdet(v, delta, x) | |
%PEAKDET Detect peaks in a vector | |
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local | |
% maxima and minima ("peaks") in the vector V. | |
% MAXTAB and MINTAB consists of two columns. Column 1 | |
% contains indices in V, and column 2 the found values. | |
% | |
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices | |
% in MAXTAB and MINTAB are replaced with the corresponding | |
% X-values. |
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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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
# This is a modification of the blogpost on how to use Mongoid and Sinatra. | |
# Here is the original blogpost http://www.garrensmith.com/2010/09/11/Mongoid-sinatra.html | |
# The modification lets you use Mongoid 3.0 with the new Moped driver | |
# The new Moped driver uses the Sessions component to define the MongoDB connection rather | |
# than the Mongo::Connection.new that is used in the case of the default Ruby driver. | |
# Moped::Session.new vs Mongo::Connection.new | |
# Mongoid.load!(yaml_config.yml) is used to build the config hash. Alternatively, the hash can | |
# be built manually by using Mongoid.config {|config| ...} syntax. The config.sessions hash |
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
-- 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%' |
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
function zeroCells() { | |
var ss=SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet=ss.getSheets()[0]; | |
var selection=sheet.getDataRange(); | |
var columns=selection.getNumColumns(); | |
var rows=selection.getNumRows(); | |
for (var column=1; column < columns; column++) { | |
for (var row=1; row < rows; row++) { | |
var cell=selection.getCell(row,column); | |
if (cell.isBlank()) { |
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
∧,_,∧ | |
(`・ω・´) n__ | |
`__n 〉 ⌒\/ 、_∃ | |
E_,У ∧ \_/ | |
\_/ \ 丶 | |
/ y ノ | |
/ / / | |
( ( 〈 | |
\ \ \ | |
(_(__) |
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
Δ~~Δ | |
ξ •ェ• ξ | |
ξ ~ ξ | |
ξ ξ | |
ξ ⌒~~~~〇 | |
ξ , ξ | |
ξ ξξ ξ~~~ξ ξ | |
ξ_ξ ξ_ξ ξ_ξ |
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
# RVM sudo. | |
rvmsudo passenger-install-nginx-module | |
rvmsudo ruby test.rb | |
# Root console. | |
sudo clear; sudo gnome-terminal 2>/dev/null & | |
# Find service: | |
ps aux | grep 'nginx' |
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
┏┳━━━━━━┳┓ | |
┃┃・ ▼ ・┃┃ | |
┃┃〃┗┻┛〃┃┃ | |
┗┫┏┓ ┏┓ ┣┛ | |
┗┫ ┣━┫┣━┛ |
OlderNewer