Skip to content

Instantly share code, notes, and snippets.

View fmtarif's full-sized avatar

Faisal Muhammad fmtarif

View GitHub Profile
@fmtarif
fmtarif / netbeans-shortcuts.txt
Last active August 29, 2015 14:06
#IDE Cool netbeans shortcuts - Cool = those i use frequently ;-)
ALT SHIFT O to search and open a file
CTRL SHIFT 1 to select current in project
SHIFT + ESC to full screen current window (i always keep two splitted windows and toggle betn full screen)
CTRL E to del line
CTRL SHIFT UP/DOWN to duplicate
ALT SHIFT UP/DOWN to move
ALT 1 to open terminal in current file path (QuickOpener plugin)
ALT 2 to open explorer in current file path (QuickOpener plugin)
@fmtarif
fmtarif / command-line-shortcuts.txt
Last active October 23, 2017 15:18
#linux #cli Command line editing shortcuts
-- From http://stackoverflow.com/a/16687377
Clean up the line: You can use Ctrl+U to clear up to the beginning if cursor is at end.
Clean up the line: Ctrl+K to wipe the current line in the terminal if cursor is at beginning
Cancel the current command/line: Ctrl+C.
Recall the deleted command: Ctrl+Y
Go at the beginning of the line: Ctrl+A
Go at the end of the line: Ctrl+E
Remove the forward words for example, if you are middle of the command: Ctrl+K
Remove characters on the left, until the beginning of the word: Ctrl+W
@fmtarif
fmtarif / random-number.js
Created October 20, 2014 10:57
#js return a random number from a range in javascript
var max = 50,
min = 10;
var random = Math.floor(Math.random() * (max-min) + min) //will return a random int within the range min to max
alert(random);
//so if min is 0 then it simply becomes
//Math.floor(Math.random() * max)
@fmtarif
fmtarif / array_assignment_by_value.php
Created November 18, 2014 09:47
#php Array assignment by reference or by value dilemma
<?php
//Array assignment always involves value copying. Use the reference operator to copy an array by reference.
//http://php.net/manual/en/language.types.array.php#example-109
$email = array();
$code = array();
$res = array(
'email' => $email //use &$email
@fmtarif
fmtarif / iframe-preview.html
Created December 9, 2014 15:47
#js #html real time preview in iframe
<!doctype html>
<html>
<head>
<title>Real time preview in iframe</title>
<style>
* { margin: 0; }
html, body { height: 100%; } .pane { height: 100%; } /*why doesn't this work '*/
.pane {
float: left;
width: 49%;
@fmtarif
fmtarif / reset-form-fields.js
Last active August 29, 2015 14:11
#js #jquery reset form fields when there is no form tag
$("#someID").find("input").each(function(i,e) {
var $this = $(this);
$this.val('');
$this.val($this.attr('value')) //defaults
});
$("#someID").find("select").prop("selectedIndex", 0); //make first value selected, not actually default but mostly the use case is such
@fmtarif
fmtarif / SEAF.js
Last active August 29, 2015 14:11
#js self executing anonymous function explained
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<script>
/*
function test_alert(foo) {
@fmtarif
fmtarif / database-backup-alt.sh
Created December 27, 2014 14:01
#linux #sysadmin #bash - DB backup script with log messages
#!/bin/sh
# from http://unix.stackexchange.com/a/125727
now="$(date +'%d_%m_%Y_%H_%M_%S')"
filename="db_backup_$now".gz
backupfolder="/var/www/vhosts/example.com/httpdocs/backups"
fullpathbackupfile="$backupfolder/$filename"
logfile="$backupfolder/"backup_log_"$(date +'%Y_%m')".txt
echo "mysqldump started at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile"
mysqldump --user=mydbuser--password=mypass --default-character-set=utf8 mydatabase | gzip > "$fullpathbackupfile"
echo "mysqldump finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile"
@fmtarif
fmtarif / umask.txt
Last active October 23, 2017 15:18
#linux #cli umask - user file-creation mode mask
#View current umask for current user
umask
#tmp set umask for current user
umask 0002 (octal values)
umask u=rwx,g=rwx,o=r #sybolic values
#Calculating The Final Permission For FILES
You can simply subtract the umask from the base permissions to determine the final permission for file as follows:
666 - 022 = 644 (rw-r--r--)
@fmtarif
fmtarif / snippets.js
Created January 18, 2015 07:16
#js #jquery snippets
//get all texts joined by a delimiter from a selector that returns multiple elements
//useful for getting all links for example from youtube page, extract names from list etc
$("ul li").map(function() {return $(this).text()}).get().join("\n")
$("ul li").map(function() {return $(this).text()}).get().join(",")