Skip to content

Instantly share code, notes, and snippets.

View kocoten1992's full-sized avatar
😗
Thanks for visiting

Chuong kocoten1992

😗
Thanks for visiting
View GitHub Profile
@dominicmartineau
dominicmartineau / gist:5957140
Last active December 19, 2015 12:48
Laravel 4: How to redirect to 404 page after exception thrown. Simply add a redirect to your 404 page at the end of 'App::error()' into app/start/global.php. You should return to your 404 page only if debug is not enabled.
App::error(function(Exception $exception, $code)
{
Log::error($exception);
if (Config::get('app.debug') == false) {
return Redirect::route('404');
}
});
@bobthecow
bobthecow / reflection.php
Created October 29, 2014 17:37
PHP is the best at reflection.
<?php //\\ dɥd¿>
;namespace ǝɔɐdsǝɯɐu;
class ssɐlɔ
{ //\\ }
function uoıʇɔunɟ
( )
{ //\\ }
;echo oɥɔǝ;
@DeviaVir
DeviaVir / mysql-cluster.service
Created March 7, 2017 09:23
MySQL Cluster systemd service
[Unit]
Description=MySQL Cluster server
After=network.target auditd.service
[Service]
ExecStart=/opt/mysql/server-5.7/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

All about database

Because you know I am all about database
database, database, but no trigger (4x)

I am about database, base, base

Yeah it ain't clear
This font is size 2
@kn007
kn007 / test.php
Last active February 26, 2021 07:46
performance: mt_rand vs openssl_random_pseudo_bytes vs random_bytes vs uniqid vs uuid
<?php
define('LOOP_COUNT',100000);
function create_uuid_v4(){
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
@RichardBronosky
RichardBronosky / README.md
Last active July 19, 2021 09:18
Create a single-file "unified format" ovpn file from the legacy client.ovpn client.key client.crt ca.crt four-file format.

unify-ovpn.sh

  1. cd to the directory where your 4 files are. (client.ovpn, client.key, client.crt, and ca.crt)

  2. Call unify-ovpn.sh with the filename of your ovpn file

     unify-ovpn.sh client.ovpn
    
  3. A new file named client_unified.ovpn will be created

@bobvawter
bobvawter / contention.sql
Last active November 10, 2021 21:02
Summarize contention events in CockroachDB
WITH c AS (
SELECT DISTINCT ON (table_id, index_id)
table_id,
index_id,
num_contention_events AS events,
cumulative_contention_time AS times
FROM crdb_internal.cluster_contention_events
)
SELECT i.descriptor_name, i.index_name, c.events, c.times
FROM crdb_internal.table_indexes AS i
@JeffreyWay
JeffreyWay / .bash_profile
Created July 31, 2015 19:20
Prettier git logs
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@drfill
drfill / gist:c18308b6d71ee8032efda870b9be348e
Created October 26, 2017 17:58 — forked from Mindgames/gist:556dc7d1e452d0cefcb7
Amazon S3 download with Curl
#!/bin/sh
file=path/to/file
bucket=your-bucket
resource="/${bucket}/${file}"
contentType="application/x-compressed-tar"
dateValue="`date +'%a, %d %b %Y %H:%M:%S %z'`"
stringToSign="GET
${contentType}
${dateValue}
${resource}"
@ezzatron
ezzatron / num-cpus.php
Created October 28, 2011 03:53
Function to detect number of CPUs in PHP
<?php
/**
* Copyright © 2011 Erin Millard
*/
/**
* Returns the number of available CPU cores
*
* Should work for Linux, Windows, Mac & BSD