Skip to content

Instantly share code, notes, and snippets.

View muhtarudinsiregar's full-sized avatar
🎯
Focusing

mhtrdn muhtarudinsiregar

🎯
Focusing
View GitHub Profile
@resmall
resmall / gist:51b328aa303b15979e77
Last active December 18, 2024 03:38
Imports an sql file and execute the script in Laravel Seeder
public function run() {
DB::unprepared(File::get('path/to/SQL/file'));
}
@fractefactos
fractefactos / pivot_example.php
Last active October 17, 2022 08:47 — forked from lighta971/pivot_example.php
Laravel Custom Pivot Model definition example
<?php
//https://github.com/laravel/framework/issues/2093#issuecomment-39154456
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Pivot;
class User extends Eloquent {
public function groups() {
return $this->belongsToMany('Group');
@youralien
youralien / download_sbu_multi.py
Created July 31, 2015 04:28
scrape and save images FAST using multiprocessing
import os
from time import time
import urllib
import multiprocessing
from progressbar import ProgressBar
img_dir = '/home/luke/datasets/sbu/images'
def get_sbu_urls():
# read in urls
@carcinocron
carcinocron / debugger pause beforeunload
Last active July 22, 2025 08:53
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@stephen-puiszis
stephen-puiszis / elasticsearch-cheatsheet.txt
Last active August 23, 2025 14:22
Elasticsearch Cheatsheet - An Overview of Commonly Used Elasticsearch API Endpoints and What They Do
# Elasticsearch Cheatsheet - an overview of commonly used Elasticsearch API commands
# cat paths
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/indices
/_cat/indices/{index}
@jatubio
jatubio / getRandomTimestamps
Last active November 26, 2020 11:52
Get random dates for created_at and updated_at fields on Laravel Framework using Carbon package
<?php
function getRandomTimestamps($backwardDays = null)
{
if ( is_null($backwardDays) )
{
$backwardDays = -800;
}
@kwmiebach
kwmiebach / pytest.md
Last active October 28, 2025 14:04 — forked from amatellanes/pytest.sh
pytest cheat sheet

Usage

(Create a symlink pytest for py.test)

pytest [options] [file_or_dir] [file_or_dir] ...

Help:

@ikeikeikeike
ikeikeikeike / zero_downtime_reindexing.py
Created March 30, 2015 04:15
Elasticsearch Zero Downtime Reindexing using elasticsearch-dsl-py ref: https://www.elastic.co/blog/changing-mapping-with-zero-downtime
from datetime import datetime
from elasticsearch_dsl import (
DocType,
String,
Integer,
Float
)
def _suffix():
@Michael-Brooks
Michael-Brooks / passwordValidation.php
Last active July 7, 2024 03:44
Laravel Password validation Regex (Contain at least one uppercase/lowercase letters and one number)
<?php
/*
* Place this with the rest of your rules.
* Doesn't need to be in an array as there are no pipes.
* Password is required with a minimum of 6 characters
* Should have at least 1 lowercase AND 1 uppercase AND 1 number
*/
$rules = [
'password' => 'required|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'
];