Skip to content

Instantly share code, notes, and snippets.

View randolphledesma's full-sized avatar

Randolph Ledesma randolphledesma

  • Zylun
  • Cebu City
View GitHub Profile
@randolphledesma
randolphledesma / .htaccess
Last active October 24, 2018 03:19
Useful Htaccess
<Files "server.js">
Order Allow,Deny
Deny from all
</Files>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
; Sample stunnel configuration file for Unix
; PID file is created inside the chroot jail (if enabled)
pid = /var/run/stunnel4.pid
; Debugging stuff (may be useful for troubleshooting)
;debug = 7
;output = /var/log/stunnel4/stunnel.log
; **************************************************************************
; * Service defaults may also be specified in individual service sections *
@randolphledesma
randolphledesma / stunnel.conf
Created October 22, 2018 04:09
Stunnel config
; Sample stunnel configuration file for Unix by Michal Trojnara 2002-2014
; Some options used here may be inadequate for your particular configuration
; This sample file does *not* represent stunnel.conf defaults
; Please consult the manual for detailed description of available options
; **************************************************************************
; * Global options *
; **************************************************************************
; A copy of some devices and system files is needed within the chroot jail
@randolphledesma
randolphledesma / notes.md
Created September 26, 2018 23:25
Nodejs notes

Installing nodejs for debian

curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
@randolphledesma
randolphledesma / script.php
Created September 13, 2018 00:25
Array map
<?php
$the_pids = [1,2,3,4];
$filter_pids = implode(' OR ', array_map( function($pid){ return 'pid=' . $pid; }, $the_pids ) );
@randolphledesma
randolphledesma / script.php
Created August 31, 2018 02:49
PHP: Find function declaration
<?php
/*
@see https://stackoverflow.com/questions/2222142/how-to-find-out-where-a-function-is-defined
*/
$reflFunc = new ReflectionFunction('function_name');
print $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
@randolphledesma
randolphledesma / .htaccess
Created August 2, 2018 02:57
Apache htaccess redirect and discard query string
RewriteEngine On
RewriteCond %{QUERY_STRING} .*
RewriteRule .* https://httpbin.org/? [R=301]
@randolphledesma
randolphledesma / .git_hooks_pre-commit
Created July 31, 2018 23:37
Git pre-commit hook example
@ref https://github.com/nicklockwood/SwiftFormat#git-pre-commit-hook
#!/bin/bash
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
swiftformat "${line}";
git add "$line";
done
@randolphledesma
randolphledesma / command.php
Created May 24, 2018 00:44
PHP Shell Task Template
<?php
ini_set('memory_limit', '256M');
function stdoutlog($msg)
{
fwrite(STDOUT, date('Y-m-d G:i:s') . ' ');
fwrite(STDOUT, $msg);
fwrite(STDOUT, PHP_EOL);
}
@randolphledesma
randolphledesma / linux.txt
Created May 9, 2018 22:27
Linux notebook
My library for very useful Linux commands