Skip to content

Instantly share code, notes, and snippets.

@melloc01
melloc01 / gist:31035434e7c1f64d1583
Last active September 23, 2015 22:30
Default API Apache Config
<VirtualHost *:80>
ServerName api.sellead.dev
DocumentRoot /var/www/sellead.dev/api/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sellead.dev/api>
Conexões Internet Ativas (sem os servidores)
Proto Recv-Q Send-Q Endereço Local Endereço Remoto Estado
tcp 0 0 dev.local:46284 189.103.27.109:https ESTABELECIDA
tcp 1 0 bd6710e1.virtua.c:59381 209-20-75-76.slice:http ESPERANDO_FECHAR
tcp 0 0 localhost:46727 localhost:2222 ESTABELECIDA
tcp 0 0 dev.local:54110 gru09s17-in-f5.1e:https ESTABELECIDA
tcp 0 0 dev.local:35543 173.194.219.94:https ESTABELECIDA
tcp 0 0 dev.local:45580 189.103.27.106:https ESTABELECIDA
tcp 0 0 localhost:2222 localhost:46727 ESTABELECIDA
tcp 0 0 dev.local:33103 64.233.186.189:https ESTABELECIDA
var xhr = new XMLHttpRequest(); //to reuse o intervals. Creating one for each request causes heavy CPU load
var CommentBox = React.createClass({
getInitialState: function() {
return {data: []};
},
loadCommentsFromServer: function() {
var cp = this;
var MersenneTwister = function(seed) {
if (seed == undefined) {
seed = new Date().getTime();
}
/* Period parameters */
this.N = 624;
this.M = 397;
this.MATRIX_A = 0x9908b0df; /* constant vector a */
this.UPPER_MASK = 0x80000000; /* most significant w-r bits */
@melloc01
melloc01 / gist:1f2b42aff2e73d7f2f17
Last active August 29, 2015 14:23
Como fazer uma requisição à uma API com Javascript puro
function XhrRequestExample {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200){
//handle success
@melloc01
melloc01 / gist:b3136736164ac45433e7
Created June 24, 2015 18:03
Max watched files by Unix
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@melloc01
melloc01 / gist:2117789c2a400b8d21f6
Created June 24, 2015 18:07
Ubuntu provisioning
sudo apt-get update && apt-get update
apt-get install apache2 php5 php5-mcrypt git
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
sudo npm install -g grunt-cli bower gulp
sudo apt-get install php5-dev php-pear
var xmlhttp = new XMLHttpRequest(); // esse carinha faz requisições
// aqui você prepara a função de callback (caso queira usar) | função que vai ser chamada depois da resposta do servidor
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) { // quando a requisição tiver sucesso
var dados = JSON.parse(xmlhttp.responseText); // caso a resposta do servidor seja em JSON
// faça o que quiser
}
echo ==== deploying application =====
echo ========= checking out =========
git --work-tree=/var/www/projeto/api/src --git-dir=/var/www/projeto/api/repository.git checkout -f
echo ========= installing dependencies =========
( cd /var/www/projeto/api/src && composer install && php artisan migrate )
echo =========== complete ===========
@melloc01
melloc01 / Fix Linux permissions
Last active May 4, 2016 18:04
Fix unix file & dir permissions
sudo find . -type d -exec chmod 775 {} \; && find . -type f -exec chmod 664 {} \;