Skip to content

Instantly share code, notes, and snippets.

@chongkan
chongkan / Diputados.php
Last active June 5, 2018 00:31
Diputadas y Diputados de Costa Rica en Formato JSON
<?php
include('simple_html_dom.php');
$diputadosCostaRica = new DiputadosCostaRica();
$diputadosCostaRica->index();
@chongkan
chongkan / install-pre-commit.sh
Created December 8, 2016 20:12 — forked from stefansundin/install-pre-commit.sh
Git pre-commit check to stop accidental commits to master and develop branches. There is also a variant with a core.whitespace check.
#!/bin/sh
# This script will install a Git pre-commit hook that stop accidental commits to master and develop branches.
# There is also a variant that includes a core.whitespace check. See pre-commit-2 below.
# Install in current Git repo:
# curl -fL https://gist.githubusercontent.com/stefansundin/9059706/raw/install-pre-commit.sh | sh
# Install with core.whitespace check:
# curl -fL https://gist.githubusercontent.com/stefansundin/9059706/raw/install-pre-commit.sh | sh -s pre-commit-2
# Install with core.whitespace check and EOF-newline-check:
# curl -fL https://gist.githubusercontent.com/stefansundin/9059706/raw/install-pre-commit.sh | sh -s pre-commit-3
# Install only core.whitespace check:
<?php
include('simple_html_dom.php');
$propuestasPopularesAsamblea = new propuestasPopularesAsamblea();
$propuestasPopularesAsamblea->index();
@chongkan
chongkan / gist:29ccd9b79b7104ebd8350250b3c25997
Created November 16, 2016 01:01
Are you a Costarrican or a Costarrican't?
Are you a Costarrican or a Costarrican't?
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
[user]
name = Eduardo Chongkan
@chongkan
chongkan / Elasticsearch install script
Created October 1, 2015 19:16 — forked from ThomasArdal/Elasticsearch install script
Script to setup Elasticsearch on Linux
#!/usr/bin/env bash
# update apt
sudo apt-get update
# install java
sudo apt-get install openjdk-7-jre-headless -y
# install elasticsearch
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb
public function update(UpdateCampaignRequest $request, $id)
{
$campaign = Campaign::findOrFail($id);
//A. Update all Regular Fields
$campaign->update($request->all());
//B. Update Terms
// B.1. Delete all terms to write a new list
@chongkan
chongkan / gist:1c7b9e3648960ce7ccdf
Last active August 29, 2015 14:25
Laravel Route for retrieving logs via browser.
// Authentication based on PingPong Admin package. Use your own authentication package as filter or remove this filter. ( not recommendd )
Route::get('getLog', array('before' => 'admin.auth', function() {
$path = storage_path() . "/logs/";
$date = Input::get('date');
try {
if (!isset($date)) {
$latest_ctime = 0;
$latest_filename = '';
@chongkan
chongkan / LaravelBatchUpdateDB
Created July 15, 2015 17:46
Laravel BatchUpdate DB Query
//http://stackoverflow.com/questions/26133977/laravel-bulk-update
public function updateBatch($tableName = "", $multipleData = array()){
if( $tableName && !empty($multipleData) ) {
// column or fields to update
//var_dump($multipleData);
$updateColumn = array_keys($multipleData[0]);
//var_dump($updateColumn);
@chongkan
chongkan / etchosts.sh
Last active August 29, 2015 14:20 — forked from mikeflynn/etchosts.sh
#!/bin/bash
HOSTSFILE="/etc/hosts"
BAKFILE="$HOSTSFILE.bak"
DOMAINREGEX="^[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]+$"
IPREGEX="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
URLREGEX="^https?:\/\/[a-zA-Z0-9]{1}[a-zA-Z0-9\/\.\-]+$"
backup()
{