Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <math.h>
#include <stack>
#include <iomanip>
#include <stdio.h>
using namespace std;
typedef unsigned long long llu;
int main(){
// freopen("in.txt","r",stdin);
@steve-chavez
steve-chavez / gist:6097026
Created July 28, 2013 01:53
TIMUS 1001 STACK AND VECTOR
// VECTOR
#include <math.h>
#include <vector>
#include <stdio.h>
using namespace std;
int main(){
double x;
vector<double> xs;
@steve-chavez
steve-chavez / django_hasher.py
Created July 1, 2014 18:22
Use django hasher to make password
./manage.py shell
from django.contrib.auth.hashers import make_password, HASHERS
make_password('test')
'pbkdf2_sha256$10000$vkRy7QauoLLj$ry+3xm3YX+YrSXbri8s3EcXDIrx5ceM+xQjtpLdw2oE='
make_password('test', 'abc')
'pbkdf2_sha256$10000$abc$MqJS5OAgSmf9SD9mfoY8fgLo8sSKmEcef0AjjMp1Q7w='
sass-convert --from css --to scss vendor/jquery-ui/css/jquery-ui.css > styles/scss/vendor/_jquery-ui.scss
@steve-chavez
steve-chavez / ajaxxhr.js
Last active August 29, 2015 14:04
Make ajax requeste with no library
var success = function(){
console.log(this.responseText);
if(typeof callback === 'function')
callback();
};
var error = function(){
console.log('=>error');
};
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://ksapirest.herokuapp.com/v1/sessiontvs/43037", true);
upstream app_server_djangoapp {
server localhost:8002 fail_timeout=0;
}
server {
listen 80;
server_name www.karaokesmart.co;
#server_name ec2-22-214-31-98.us-west-2.compute.amazonaws.com;
location ~ ^/(lgproduccion|prueba)/? {
proxy_set_header HOST www.karaokesmart.com.mx;
#!/bin/bash
set -e
LOGFILE=/usr/local/virtualenvs/ks_env/ks.webapp2/kswebapp2.log
ERRORFILE=/usr/local/virtualenvs/ks_env/ks.webapp2/error.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var samples = [];
for( var i=0; i<1000; i++){ samples[i] = getRandomInt(-128,127);}
var floats = new Float32Array(samples.length);
samples.forEach(function( sample, i ) {
floats[i] = sample < 0 ? sample / 0x80 : sample / 0x7F;
});
var ac = new webkitAudioContext()
@steve-chavez
steve-chavez / test_one_setup_django.py
Last active August 29, 2015 14:05
Django one time setup in test
from django.test import TestCase
from django.contrib.auth.models import User
from payments.models import Customer
# To allow test setup run only one time these workaround can be used
class CustomerModelTest(TestCase):
@classmethod
def setUpClass(cls):
cls.user = User.objects.create_user(username="test@est.com",
Bacon = require('baconjs')
Imm = require('immutable')
React = require('react')
window.Actions =
changeFirstName: new Bacon.Bus()
changeLastName: new Bacon.Bus()
changeCountry: new Bacon.Bus()
addCountryBird: new Bacon.Bus()
addFriend: new Bacon.Bus()