Skip to content

Instantly share code, notes, and snippets.

View lslucas's full-sized avatar

Lucas Serafim lslucas

View GitHub Profile
@lslucas
lslucas / mongoimport.sh
Last active December 15, 2015 10:49
Mongo Import a single json file to a new collection
#import a single json file
$ mongoimport -h 127.0.0.1 -c subprovider -db techtravel --file subprovider.json
#import csv file
$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline
#export a single collection
$ mongoexport --db techtravel --collection subprovider --out /var/www/techtravel/storage/database/2013-04-03/subprovider.json
#export a single collection but specific data from that collection
$environments = array(
'development' => array('http://localhost*', '*.dev'),
'production' => array('http://mywebsite.com*', '*.mywebsite.com'),
);
@lslucas
lslucas / gist:4551402
Created January 16, 2013 22:07
phpize and pecl problem
$ sudo pecl install mongo
downloading mongo-1.3.3.tgz ...
Starting to download mongo-1.3.3.tgz (122,098 bytes)
...........................done: 122,098 bytes
49 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
yum remove php-common # Need to remove this, otherwise it conflicts
yum install php56w
yum install php56w-mysql
yum install php56w-common
yum install php56w-pdo
yum install php56w-opcache
php --version
sudo ssh-keygen -t rsa -b 4096 -C eishii1
@lslucas
lslucas / gist:3820715
Created October 2, 2012 16:27
Vagrant ssh fails with VirtualBox
Problem:
$ vagrant up
[default] VM already created. Booting if its not already running...
[default] Running any VM customizations...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- ssh: 22 => 2222 (adapter 1)
[default] -- db2: 30003 => 30003 (adapter 1)
[default] Cleaning previously set shared folders...
@lslucas
lslucas / .profile
Created September 27, 2012 14:43
Show current branch on git repo folder. Colorized
## based on http://www.developerzen.com/2011/01/10/show-the-current-git-branch-in-your-command-prompt/
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
BLUE="[\033[0;34m\]"
DARK_BLUE="[\033[1;34m\]"
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
@lslucas
lslucas / Iframe Javascript ContentFunctions
Created January 18, 2012 19:33
Execute (outside iframe) javascript function (inside iframe)
#vc dentro de Iframeid
parent.document.getElementById("IframeId");
#vc fora dos iframes tentando chamar uma funcão javascript que está dentro de um iframe
document.getElementById("IframeId").contentWindow.HelloWorld();
#pegar conteúdo do iframe
var iframe = parent.document.getElementById( "iframeReport");
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
@lslucas
lslucas / delicious.php
Created June 27, 2011 17:29 — forked from thiagosf/delicious.php
Funçoes para resgatar dados do Delicious
<?php
// Mais informações
// http://www.delicious.com/help/feeds
// Count
function delicious_count($url) {
$count = 0;
@lslucas
lslucas / Calcula distancias pela latitude e longitude
Created October 25, 2010 16:03
PHP: Calcula distancias pela latitude e longitude
/*
* Calcula distancias
*/
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
@lslucas
lslucas / Tweet Count
Created October 25, 2010 16:01
conta número de tweets que um determinado link teve
<?php
/*
* usage: echo tweetCount('http://google.com');
* ref: http://www.phpsnippets.info/get-how-many-times-a-page-have-been-retweeted-using-php
*/
function tweetCount($url) {
$content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url);
$element = new SimpleXmlElement($content);
$retweets = $element->story->url_count;
if($retweets){