Skip to content

Instantly share code, notes, and snippets.

View nmfzone's full-sized avatar
🍿
I'm hungry

Nabil Muhammad Firdaus nmfzone

🍿
I'm hungry
View GitHub Profile
@nmfzone
nmfzone / docs_mysqli_result.php
Last active April 16, 2022 08:49
Mysqli Result
function mysqli_result($res, $row=0, $col=0){
$numrows = mysqli_num_rows($res);
if ($numrows && $row <= ($numrows-1) && $row >=0){
mysqli_data_seek($res,$row);
$resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res);
if (isset($resrow[$col])) {
return $resrow[$col];
}
}
return false;
@nmfzone
nmfzone / UsersController.php
Last active April 5, 2017 11:59
UsersController - Example - CodeIgniter
<?php
class UsersController extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('user_model', 'user');
}
@nmfzone
nmfzone / User.php
Created October 10, 2016 17:26
Automatic Deleteing Related Key (Relationship Laravel)
class User extends Model
{
public static function boot()
{
parent::boot();
static::deleted(function ($user) {
foreach($user->articles as $article) {
$article->delete();
}
@nmfzone
nmfzone / IdDiffFormatter.php
Created September 6, 2016 18:37 — forked from herusdianto/IdDiffFormatter.php
Laravel Carbon Difference For Humans Bahasa Indonesia
<?php namespace Acme\DiffFormatters;
// app/Acme/DiffFormatters/IdDiffFormatter.php
use Laravelrus\LocalizedCarbon\DiffFormatters\DiffFormatterInterface;
use Lang;
class IdDiffFormatter implements DiffFormatterInterface {
/**
@nmfzone
nmfzone / SieveOfAtkin-Java.java
Created September 1, 2016 07:25 — forked from hephaestus9/SieveOfAtkin-Java.java
Sieve Of Atkin - Java
/*
* The function of this class is to find all prime numbers in range given by the user.
*
* This homework assignment requires several references:
* http://www.avajava.com/tutorials/lessons/how-do-i-use-threads-join-method.html
* http://stackoverflow.com/questions/1428786/best-way-to-find-a-prime-number
* http://web.mit.edu/16.070/www/lecture/big_o.pdf
* http://en.wikipedia.org/wiki/Sieve_of_Atkin
* http://stackoverflow.com/questions/3790142/java-equivalent-of-pythons-rangeint-int
* http://stackoverflow.com/questions/17279519/removing-items-from-list-in-java
@nmfzone
nmfzone / MessagesTranslationServiceProvider.php
Last active March 18, 2023 17:25
Laravel language files on custom directory
// Create MessagesTranslationServiceProvider
// example in : app/Providers/MessagesTranslationServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Services\MessagesTranslator;
@nmfzone
nmfzone / compat_l5.php
Created May 31, 2016 15:45 — forked from vluzrmos/compat_l5.php
Lumen L5 compatibility helpers. That file should be added on root path of your project... and added to your composer.json
<?php
if(!function_exists('config_path'))
{
/**
* Return the path to config files
* @param null $path
* @return string
*/
function config_path($path=null)
@nmfzone
nmfzone / gist:2dc02fb73f30c47faf39005bd21d6331
Last active June 7, 2020 02:53 — forked from bigsnarfdude/gist:b2eb1cabfdaf7e62a8fc
Install Scala 2.11.8 and sbt 13.11 in Ubuntu 14.04
# Scala Installation
wget www.scala-lang.org/files/archive/scala-2.11.8.deb
sudo dpkg -i scala-2.11.8.deb
# sbt Installation
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
sudo apt-get update
sudo apt-get install sbt
@nmfzone
nmfzone / install.sh
Created March 9, 2016 10:42 — forked from Reddine/install.sh
Install Theano on Ubuntu 14.04
sudo apt-get install build-essential
sudo apt-get update
# BLAS → LAPACK → ATLAS → numpy → scipy → Theano
# remove numpy and scipy
sudo apt-get remove python-numpy
sudo apt-get remove python-scipy
# Instalation commands
sudo apt-get install gfortran
sudo apt-get install libopenblas-dev
sudo apt-get install liblapack-dev
@nmfzone
nmfzone / gulp-resize-and-minify-images.js
Created February 3, 2016 13:10 — forked from ryantbrown/gulp-resize-and-minify-images.js
Gulp - Resize and Optimize / Minify Images
/**
* Make sure Graphicsmagick is installed on your system
* osx: brew install graphicsmagick
* ubuntu: apt-get install graphicsmagick
*
* Install these gulp plugins
* glup, gulp-image-resize, gulp-imagemin and imagemin-pngquant
*
* Group images according to their output dimensions.
* (ex: place all portfolio images into "images/portfolio"