Skip to content

Instantly share code, notes, and snippets.

View andreicristianpetcu's full-sized avatar

Andrei Petcu andreicristianpetcu

  • Bucharest, Romania
View GitHub Profile
def find_in_batches(model)
current_batch, count = 0, model.count
while count > 0 do
model.all.skip(current_batch * 1000).limit(1000).each do |doc|
yield doc
end
count -= 1000
current_batch += 1
end
@audreyt
audreyt / posa.mkdn
Last active October 12, 2021 01:06
EtherCalc Chapter for the upcoming book "The Performance of Open Source Applications" - Draft - comments welcome!

From SocialCalc to EtherCalc

Previously, in The Architecture of Open Source Applications, I described SocialCalc, an in-browser spreadsheet system that replaced the server-centric WikiCalc architecture. SocialCalc performs all of its computations in the browser; it uses the server only for loading and saving spreadsheets.

For the Socialtext team, performance was the primary goal behind SocialCalc's design in 2006. The key observation was this: Client-side computation in JavaScript, while an order of magnitude slower than server-side computation in Perl, was still much faster than the network latency incurred during AJAX roundtrips:


WikiCalc and SocialCalc's performance model

******
@ekinertac
ekinertac / nginx.conf
Created May 6, 2013 10:37
nginx: port forwarding
server{
listen 80;
server_name example.com;
access_log /home/path_to_site/access.log;
error_log /home/path_to_site/error.log;
location / {
proxy_pass http://0.0.0.0:8002;
proxy_set_header Host $host;
macro $if {
rule {
($x...)
} => {
if (relCar($x...))
}
}
macro $while {
rule {
@brenopolanski
brenopolanski / install-firefox-nightly.md
Created July 30, 2014 00:34
Install Firefox Nightly in Ubuntu via PPA

via: http://www.webupd8.org/2011/05/install-firefox-nightly-from-ubuntu-ppa.html

Add the Mozilla Daily PPA (available for Ubuntu 11.04, 10.10 and 10.04) and install Firefox Nightly using the commands below:

$ [sudo] add-apt-repository ppa:ubuntu-mozilla-daily/ppa
$ [sudo] apt-get update
$ [sudo] apt-get install firefox-trunk

Since this is a daily builds PPA, it's nowhere near stable so use it at your own risk!

@Noitidart
Noitidart / _ff-addon-snippet-ManipulateAddonAutoUpdate.js
Created August 19, 2014 07:53
_ff-addon-snippet-ManipulateAddonAutoUpdate - This shows how to manipulate an addon's auto-update setting programatically. Good thing about this is that when you programtically set it while the tab with the add-ons "More" or "Inline Options" pane is visible, the DOM will update there as well.
Cu.import('resource://gre/modules/AddonManager.jsm');
AddonManager.getAddonByID('Profilist@jetpack', function(addon) {
console.info('addon:', addon);
console.info('addon.applyBackgroundUpdates:', addon.applyBackgroundUpdates);
addon.applyBackgroundUpdates = 0; //off
//addon.applyBackgroundUpdates = 1; //default
//addon.applyBackgroundUpdates = 2; //on
});
@yunga
yunga / Cliref.md
Last active February 1, 2024 00:56
CLIRef.md
_________ _____ _______________       _____
\_   ___ \\    \\___________   \____ / ____\     ~/.bash/cliref.md
/    \  \/|    | |   ||       _/ __ \  __\    copy/paste from whatisdb
\     \___|__  |_|_  ||    |   \  __/|_ |   http://pastebin.com/yGmGiDQX
 \________  /_____ \_||____|_  /____  /_|     yunga.palatino@gmail.com
 20160515 \/ 1527 \/         \/     \/

alias CLIRef.txt='curl -s "http://pastebin.com/raw/yGmGiDQX" | less -i'

@carols10cents
carols10cents / ruby-to-rust-cheat-sheet.md
Last active November 24, 2020 23:12
Ruby to Rust Cheat Sheet

Ruby to Rust Cheat Sheet

The goal of this is to have an easily-scannable reference for the most common syntax idioms in Ruby and Rust so that programmers most comfortable with Ruby can quickly get through the syntax differences and feel like they could read and write basic Rust programs.

What do you think? Does this meet its goal? If not, why not?

Variables

Ruby:

@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active April 13, 2024 16:19
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb