Skip to content

Instantly share code, notes, and snippets.

View ThienTranDuy's full-sized avatar
💝
Lucky

Trần Duy Thiên ThienTranDuy

💝
Lucky
View GitHub Profile
@sgmurphy
sgmurphy / url_slug.js
Created July 12, 2012 02:05
URL Slugs in Javascript (with UTF-8 and Transliteration Support)
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
@sheharyarn
sheharyarn / mongo_backup.sh
Last active January 23, 2024 16:54
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@jcefoli
jcefoli / allkeys.php
Last active November 21, 2022 11:11
List All Key/Value Pairs in Redis using the Predis Library. Assumes that Redis is running locally on default port 6379 with no password auth
<?
//Include Predis library. See https://github.com/nrk/predis for more info
require "Predis/Autoloader.php";
//Connect to Redis
Predis\Autoloader::register();
try {
$redis = new Predis\Client();
$redis = new Predis\Client(array(
"scheme" => "tcp",
@parmentf
parmentf / GitCommitEmoji.md
Last active June 16, 2024 18:45
Git Commit message Emoji
@scottopolis
scottopolis / splice-object-array.js
Last active January 31, 2023 06:54
Remove object from array of objects in Javascript
// we have an array of objects, we want to remove one object using only the id property
const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id of 37
const removeIndex = apps.findIndex( item => item.id === 37 );
// remove object
apps.splice( removeIndex, 1 );
@sagarkbhatt
sagarkbhatt / rest-controller-extend.php
Created May 11, 2017 09:16
Sample class that extends WP rest controller
<?php
/**
* Add rest api endpoint for category listing
*/
/**
* Class Category_List_Rest
*/
class Category_List_Rest extends WP_REST_Controller {
/**
@joduplessis
joduplessis / cookie-typescript-utils.ts
Created September 12, 2017 06:50
Setting, deleting and retrieving cookies in Typescript.
@akexorcist
akexorcist / index.js
Last active November 17, 2022 11:25
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@portal7
portal7 / demo.html
Last active October 4, 2022 01:46
jQuery Validator Email Domain
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<form id="myForm" name="myForm" action="#" method="POST"> <style>#email-error { display: block; color: red; }</style>
<label for="email">Email: </label>
<input id="email" name="email" type="email" minlength="6"/><br>
<input type="submit" value="Submit">
</form>
@fakihariefnoto
fakihariefnoto / Setup Golang.md
Last active October 7, 2023 22:27
Setup golang, goroot, gopath, gobin

After download and move to your interested folder, add this line to ~/.bashrc and ~/.profile

export GOPATH=$HOME/gowork
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH/bin
export GOROOT=/usr/local/go

export PATH=$PATH:$GOROOT/bin