Skip to content

Instantly share code, notes, and snippets.

View dhirajforyou's full-sized avatar
💭
Code to make life simple

dhirajforyou dhirajforyou

💭
Code to make life simple
  • Bangalore Karnataka
View GitHub Profile
@dhirajforyou
dhirajforyou / fast-delete.sh
Last active November 9, 2021 05:56
Deleting an directory can be faster with rsync instead of rm or find -delete.
#!/bin/sh
readonly empty_dir=$(mktemp -d)
readonly target_dir="$1"
rm -rf $empty_dir
mkdir $empty_dir
rsync --recursive --delete $empty_dir/ "$target_dir"/
# --delete: delete extraneous files from dest dirs (differential clean-up during sync)
@dhirajforyou
dhirajforyou / index.html
Created February 11, 2019 06:35
Page Hover Preview // source https://jsbin.com/miqanik
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Page Hover Preview</title>
<style id="jsbin-css">
.box{
display: none;
width: 100%;
@dhirajforyou
dhirajforyou / index.html
Created February 11, 2019 06:32
Page Hover Preview // source https://jsbin.com/miqanik
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Page Hover Preview</title>
<style id="jsbin-css">
.box{
display: none;
width: 100%;
#It might be the case you have redefined the shortcuts. But this is what the default is.
Ctrl+A: move to the start of the current line
Ctrl+E: move to the end of the line
Alt+F: move to the end of the next word
Alt+B: move to the start of the current or previous word
Ctrl+T: swap the two last characters, e.g.: sl<C-t> → ls
Alt+T: swap the last two words, e.g.: foo bar<M-t> → bar foo
Ctrl+U: cut the text of the current command before the cursor.
Ctrl+W: cut only the word before the cursor.
@dhirajforyou
dhirajforyou / gist:0b989e2562c90c8217ef0ec64ca3bf2c
Created November 9, 2016 11:30 — forked from gansbrest/gist:6983561
Internal redirect to another domain with proxy_pass and Nginx
server
{
listen 80;
server_name a.com b.com c.com;
location ~* ^/comment/(.*) {
proxy_set_header HOST shared.com;
# $1 - stores capture from the location on top
# $is_args will return ? if there are query params
# $args stores query params
@dhirajforyou
dhirajforyou / example.com.conf
Created November 9, 2016 11:29 — forked from a-vasyliev/example.com.conf
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key
@dhirajforyou
dhirajforyou / Mahout jar
Created April 15, 2016 03:03
Creating Mahout Jar
# Get maven and git installed/ built from source
cd ~/Documents
git clone https://github.com/apache/mahout.git
cd mahout
mvn clean package
# For specific jars: ex. mahout-math jar
# cd math
# mvn clean package
# ls target mahout-math-0.12-SNAPSHOT.jar
#Get maven
sudo apt-get install maven
#Check version
mvn -v
#Get source
git clone https://github.com/apache/maven.git ~/Documents
cd ~/Documents/maven
# create new maven snapshot
mvn install
# At last it gives the maven snapshot location, ex. ~/.m2/repository/org/apache/maven/apache-maven
@dhirajforyou
dhirajforyou / _Random.js
Created March 13, 2015 11:04
Javascript Random Number Generator Function
/*
Attaching the time stamp so that based on the returned value , we can find out when it is generated
*/
function _Random(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx-te'.replace(/[xye]/g, function (c) {
var r = Math.random() * 16 | 0;
if(c == 'e'){ var t = (new Date).getTime(); v = t}
else{var v = c == 'x' ? r : (r & 3 | 8);}
return v.toString(16);
});