Skip to content

Instantly share code, notes, and snippets.

View rendon's full-sized avatar
🧑‍🔬
Trying new things out.

Rafael Rendón rendon

🧑‍🔬
Trying new things out.
View GitHub Profile
@rendon
rendon / mongodb_max_doc_size.go
Created January 26, 2016 22:03
Testing mongoDB maximum document size storing only 64-bit IDs.
// Just out of curiosity let's see how many 64-bit IDs can we pack in a mongoDB
// document.
package main
import (
"fmt"
"math/rand"
"time"
"gopkg.in/mgo.v2"
@rendon
rendon / tw_bot.js
Created January 6, 2016 20:49
TW bot
var casper = require('casper').create();
var system = require('system');
var util = require('../lib/util');
casper.options.viewportSize = { width: 1024, height: 768*3 };
casper.options.pageSettings = { loadImages:true, loadPlugins:true, webSecurityEnabled: false };
var ID = casper.cli.args[0];
if (typeof ID == 'undefined') {
@rendon
rendon / fb_bot.js
Created January 6, 2016 20:46
FB bot
// ========================================
// ! Casper
// ! Common issues: Unsafe Javascript attempt to access frame with URL
// ! Issues: http://goo.gl/u1murB
// ! Version : 1.0
// ========================================
var fs = require('fs');
var utils = require('./src/utils');
var system = require('system');
var casper = require('casper').create();
@rendon
rendon / continents_with_countries.json
Created November 18, 2015 19:50
Continents with countries, the list is not complete.
{
"africa": {
"name": "Africa",
"names": [
"Афрыка",
"Àfrica",
"Afrika",
"Afrika",
"Afrika",
"Αφρική",
@rendon
rendon / datamaps_country_codes.txt
Created November 12, 2015 19:17
Datamaps country codes
AFG: Afghanistan
AGO: Angola
ALB: Albania
ARE: United Arab Emirates
ARG: Argentina
ARM: Armenia
ATA: Antarctica
ATF: French Southern and Antarctic Lands
AUS: Australia
AUT: Austria
@rendon
rendon / invasion_zombiev2.cpp
Created November 12, 2015 16:56
Invasion zombie v2
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
inline int64 f(int64 x) {
return x * x + (x + 1) * (x + 1);
}
inline int64 g(int64 x) {
return x * (x + 1) / 2;
@rendon
rendon / invasion_zombie_check.cpp
Created November 12, 2015 16:48
Invasion zombie check
bool check(int64 d, int64 c) {
return f(d) >= c;
}
@rendon
rendon / invasion_zombiev1.cpp
Created November 12, 2015 16:44
Invasion zombie v1
const int MAX = 1000;
//endregion
long long X, Y, N;
long long ta(long long length)
{
return length * (length + 1) / 2;
}
// Upper right
@rendon
rendon / brightness_control_i3wm.sh
Last active November 6, 2015 05:15
Some bash functions to manage screen brightness when your fn+<key> does not work.
function max() {
if [ $1 -gt $2 ]
then
echo $1
else
echo $2
fi
}
function min() {

Create instance

Using the ec2 tools:

ec2-run-instances ami-xxxxxxxx -t t2.micro -k mykeypair -g sg-xxxxxxx

Using aws:

aws ec2 run-instances --image-id ami-xxxxxx --count 1 --instance-type t2.micro --key-name mykeypair --security-groups mysecuritygroup