This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
</head> | |
<body> | |
<script> | |
/* | |
function test_alert(foo) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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--) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(",") |