Skip to content

Instantly share code, notes, and snippets.

View ceceprawiro's full-sized avatar

Cecep Prawiro ceceprawiro

View GitHub Profile
<?php
$url = "http://simas.bandaacehkota.go.id/index.php?mod=masjid&act=json_masjid&order=asc&offset=0";
$source = file_get_contents($url);
$data = json_decode($source);
$total = $data->total;
foreach ($data->rows as $row) {
@ceceprawiro
ceceprawiro / UserController.php
Last active June 23, 2016 16:27
Laravel Form Validation combination of first and last name must be Unique
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'first_name' => 'required|max:100',
'last_name' => 'required|unique:user,last_name,NULL,id,first_name,'.$request->first_name.'|max:100',
]);
....
}
@ceceprawiro
ceceprawiro / android-studio.sh
Created May 13, 2016 07:33
Simple script to run Android Studio with Genymotion
#! /bin/sh
use_genimotion=false
while :
do
case "$1" in
-g | --genymotion)
use_genymotion=true
shift 1
@ceceprawiro
ceceprawiro / composer.json
Last active April 30, 2016 16:12
Silex 1.3, Doctrine ORM untuk security plus Migration.
{
"require": {
"silex/silex" : "~1.3",
"silex/web-profiler" : "~1.0",
"symfony/http-kernel" : "~2.8",
"symfony/event-dispatcher" : "~2.8",
"symfony/filesystem" : "~2.8",
"symfony/http-foundation" : "~2.8",
"symfony/intl" : "~2.8",
"symfony/property-access" : "~2.8",
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: something warm and fuzzy
# Required-Start: vboxdrv
# Required-Stop: vboxdrv
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts suspended vagrant boxes and suspends running vagrant boxes
# Description:
### END INIT INFO
@ceceprawiro
ceceprawiro / pagination.html.twig
Last active September 20, 2015 11:26 — forked from SimonSimCity/pagination.html.twig
A gist for pagination in Twig, based on the total number of pages, the current page and some URL-settings.
{#
Source: http://dev.dbl-a.com/symfony-2-0/symfony2-and-twig-pagination/
Updated by: Simon Schick <[email protected]>
Parameters:
* currentFilters (array) : associative array that contains the current route-arguments
* currentPage (int) : the current page you are in
* paginationPath (string) : the route name to use for links
* showAlwaysFirstAndLast (bool) : Always show first and last link (just disabled)
* lastPage (int) : represents the total number of existing pages
#!/usr/bin/env bash
# rename Filename.Exention jadi filename.extension (lowercase)
find . -type f | sed 's/\(.*\/\)\(.*\)/mv "\1\2" "\1\L\2"/'
# cari semua file mp3 yang mau diproses, hasilnya disimpan di file text
find . -type f | grep mp3$ > mp3-files.txt
# baca file text tersebut sebagai array
readarray -t files < mp3-files.txt
#!/bin/sh
usage() {
echo "Usage: ./project create|remove <PROJECT> [-r<DOMAIN>]"
exit
}
create() {
# Setup variables
DIR=$1
@ceceprawiro
ceceprawiro / Orm.php
Created April 12, 2015 04:08
Library CI 3 untuk Eloquent
<?php defined('BASEPATH') or die();
/**
* Filename: application/libraries/Orm.php
*
* composer.json :
* {
* "require": {
* "illuminate/database": "5.0.27",
* "illuminate/events": "5.0.26",
@ceceprawiro
ceceprawiro / dropall.sql
Created April 2, 2015 08:29
Drop semua table dalam sebuah database.
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'DATABASE_NAME'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;