Skip to content

Instantly share code, notes, and snippets.

View juliosguz's full-sized avatar

Julio Silva juliosguz

  • Lima, Perú 🇵🇪
View GitHub Profile
@juliosguz
juliosguz / tips-mysql.sql
Last active August 29, 2015 14:11
Tips for MySql queries
# When you need only 1 records, use Limit 1
SELECT * FROM default_users WHERE username='juliosguz' LIMIT 1;
# Try to not use undetermined functions like : RND(),NOW(),CURDATE() in your queries, because some times MySql disable cache for that
SELECT * FROM default_users WHERE birthday >= NOW(); # BAD
SELECT * FROM default_users ORDER BY RAND(); # BAD ++ !!!!
SELECT * FROM default_users WHERE birthday >= 1419032756; #GOOD , this value maybe you can get with time() function in php for example
# Avoid NULL fields in your tables
#!/bin/sh
mysqlslap --concurrency=20 --iterations=1 --query="QUERY" --create-schema="DATABASE" --user="USER" --password="PASSWORD" --host="HOST"
#!/bin/sh
ssh root@IP-DOMAIN 'bash -s' < FILE.sh
@juliosguz
juliosguz / app.yaml
Created February 8, 2015 16:57
Basic app.yaml for Google App Engine
application: blog #nombre de tu aplicación
version: 1 #el numero de version de proyecto
runtime: php #lenguaje que usaras en tu proyecto
api_version: 1 #la version del runtime que estas usando
handlers:
- url: /.* #enviaremos todo lo que entre a index.php
script: index.php
@juliosguz
juliosguz / ruby-brew.sh
Last active December 13, 2016 23:23
Install Ruby with Homebrew
brew install rbenv ruby-build
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
rbenv install 2.2.3
rbenv global 2.2.3
@juliosguz
juliosguz / visual-studio-code.json
Created February 15, 2017 01:14
Settings for Visual Studio Code editor
{
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.renderWhitespace": "boundary",
"window.zoomLevel": 1,
"vsicons.projectDetection.autoReload": true
}
@juliosguz
juliosguz / firebase-database.txt
Created March 30, 2017 01:39
Basic structure of Firebase Database data
// Authentication
users
{
user1: {
email: 'julio.sguz@gmail.com',
proveedor: 'email',
creationDate: '12-04-2016'
},
user2: {
email: 'vania@gmail.com',
@juliosguz
juliosguz / set-env.ts
Created August 11, 2017 12:52
Use OS environment variable to get configuration on Angular
// This script is based from https://medium.com/@natchiketa/angular-cli-and-os-environment-variables-4cfa3b849659
import { writeFile } from 'fs';
import { argv } from 'yargs';
const environment = argv.environment;
const isProd = environment === 'prod';
require('dotenv').config({path: `./set-env/.env.${environment}`});
const targetPath = `./src/environments/environment.${environment}.ts`;
@juliosguz
juliosguz / firebase-1.txt
Last active February 17, 2018 21:23
Workshop de Firebase #1
npm install -g firebase-tools
git clone https://github.com/juliosguz/firebase-workshop
cd firebase-workshop
firebase init
firebase serve
// Subir data de pruebaˇ
firebase database:push data-structure/posts-data.json /posts
@juliosguz
juliosguz / generic-routing.module.ts
Last active March 12, 2018 22:53
NativeScript Angular snippets
import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
const routes: Routes = [];
@NgModule({
imports: [NativeScriptRouterModule.forChild(routes)],
exports: [NativeScriptRouterModule]
})