Skip to content

Instantly share code, notes, and snippets.

View sendyputra's full-sized avatar
🏠
Working from home

Sendy Putra sendyputra

🏠
Working from home
  • Indonesia
  • 10:38 (UTC +07:00)
  • X @sendypw
View GitHub Profile
@sendyputra
sendyputra / get-npm-package-version
Created September 29, 2023 14:23 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@sendyputra
sendyputra / geo.js
Created October 2, 2019 05:59 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@sendyputra
sendyputra / node-v8-options
Last active May 8, 2018 23:19
node --v8-options
SSE3=1 SSSE3=1 SSE4_1=1 SAHF=1 AVX=0 FMA3=0 BMI1=0 BMI2=0 LZCNT=0 POPCNT=1 ATOM=0
Usage:
shell [options] -e string
execute string in V8
shell [options] file1 file2 ... filek
run JavaScript scripts in file1, file2, ..., filek
shell [options]
shell [options] --shell [file1 file2 ... filek]
run an interactive JavaScript shell
d8 [options] file1 file2 ... filek
@sendyputra
sendyputra / optimize_images.sh
Created October 17, 2017 08:25 — forked from fosterdill/optimize_images.sh
Find png files that don't have transparency and convert to jpg, also recompress jpg files for the web
#!/bin/sh
echo You should have the project tracked by version control in case something goes wrong.
printf 'Press any key to continue...'
read -r
path=${1:-.}
echo Optimizing images in "$path"
if [ -z "$(command -v jpeg-recompress)" ] || [ -z "$(command -v ladon)" ] || [ -z "$(command -v mogrify)" ]; then
@sendyputra
sendyputra / cloudSettings
Last active September 24, 2019 14:53
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-09-24T14:53:11.869Z","extensionVersion":"v3.4.3"}
function whmAPI($server_ip, $root_pass, $function, $parameter = '', $type='')
{
$whmusername = "root";
if ($type == 'cpanel') {
$query = "https://" . $server_ip . ":2087/json-api/cpanel?api.version=1&cpanel_jsonapi_apiversion=2" . $parameter;
} else {
$query = "https://" . $server_ip . ":2087/json-api/" . $function . "?api.version=1" . $parameter;
}
@sendyputra
sendyputra / toAscii.php
Created December 14, 2015 10:02 — forked from chluehr/toAscii.php
PHP clean url slug generator / converter (slug)
<?php
// source: http://cubiq.org/the-perfect-php-clean-url-generator
// author: Matteo Spinelli
// MIT License / http://creativecommons.org/licenses/by-sa/3.0/ (please re-check at source)
setlocale(LC_ALL, 'en_US.UTF8');
function toAscii($str, $replace=array(), $delimiter='-') {
if( !empty($replace) ) {
$str = str_replace((array)$replace, ' ', $str);
}
<?php
/**
* Create a web friendly URL slug from a string.
*
* 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>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
#! /bin/sh
# Usage 1:
# optimize-images.sh /images/dir
#
# Usage 2:
# cd /images/dir
# optimize-images.sh
EXTENSIONS="jpe?g"
#!/opt/local/bin/php
<?php
/*
1) replace the shebang (first line) with the path to your php binary
(probably something like /usr/bin/php)
2) move the file to /usr/local/bin/datauri.php
(this should be in your PATH)
3) chmod ugo+rx /usr/local/bin/datauri.php
(make the script executable for everyone)