Skip to content

Instantly share code, notes, and snippets.

@ikawka
ikawka / htmlentity.js
Created September 20, 2018 04:20 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@ikawka
ikawka / restricted-ftp-user.sh
Last active August 12, 2023 10:03
Create an sftp user and restrict to specific folder.
#1. Create the sftp group
sudo groupadd sftpusers
#2. Comment out the default "Subsystems sftp" in the ssh config
sudo sed -i "s/Subsystem sftp \/usr\/lib\/openssh\/sftp-server/#Subsystem sftp \/usr\/lib\/openssh\/sftp-server/" /etc/ssh/sshd_config
#3. Modify the ssh config
sudo vi /etc/ssh/sshd_config
#Add the these lines to the end of the file
@ikawka
ikawka / cloudflare-trace.js
Last active December 31, 2023 12:29
Trace current user's location via javascript with CloudFlare provided the /cdn-cgi/trace is enabled.
(function($){
$(function(){
$.ajax({
contentType: 'application/text; charset=utf-8',
crossBrowser: true,
type: 'GET',
url: '/cdn-cgi/trace',
}).done(function(d){
var data = d.replace(/[\r\n]+/g, '","').replace(/\=+/g, '":"');
data = '{"' + data.slice(0, data.lastIndexOf('","')) + '"}';
@ikawka
ikawka / docker-cleanup-resources.md
Created November 10, 2017 03:26 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ikawka
ikawka / notes.php
Last active August 29, 2015 14:11
Wordpress Notes
<?php
//get current URL
global $wp;
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
//add ajax actions in the admin page
add_action( 'wp_ajax_your_action', 'yourCallback' );
function yourCallback(){
//do something here and echo
exit(); //this is important or else wordpress will echo 0 and adds to your output;
@ikawka
ikawka / gist:071414997ada38be8258
Created August 5, 2014 20:24
Android deployment signing and alignment
//generate your key
keytool -genkey -v -keystore my-release-key.keystore -alias my-app -keyalg RSA -keysize 2048 -validity 10000
//sign your apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my-app-release-unsigned.apk my-app
//align apk zipalign is usually unnder Android/sdk/build-tools/19.1.0/
zipalign -v 4 my-app-release-unsigned.apk my-app-release.apk
@ikawka
ikawka / HTML
Last active August 29, 2015 14:04
Jquery Slider Progressbar
<div id="target"></div>
@ikawka
ikawka / .vimrc
Last active August 29, 2015 14:03
Vim+NERDTree+PowerLine Configuration
execute pathogen#infect()
syntax on
filetype plugin indent on
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
set guifont=Inconsolata\ for\ Powerline:h18
set background=dark
colorscheme macvim "delek
set number
@ikawka
ikawka / gist:3d9ea79b76082cb879d9
Created June 26, 2014 09:49
ios custom view transition
http://www.thinkandbuild.it/how-to-create-custom-viewcontroller-transitions/