Skip to content

Instantly share code, notes, and snippets.

View yannbertrand's full-sized avatar
:octocat:

Yann Bertrand yannbertrand

:octocat:
View GitHub Profile
https://www.linux.com/community/blogs/133-general-linux/850945-setup-mutt-with-gmail-on-centos-and-ubuntu
# Setup a service in /etc/init.d
https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian
# Don't forget the LSB tags
http://help.directadmin.com/item.php?id=379
# Example on a script called blah:
$ update-rc.d blah defaults
@yannbertrand
yannbertrand / debian-check-open-ports
Created February 18, 2016 09:11
List open ports and check one is up
# /!\ May change whether root or not
netstat -pln [| grep PORT_NB]
@yannbertrand
yannbertrand / better-index-of.js
Created January 18, 2016 10:15
Simplify the use of indexOf
// Array
var list = ['my', 'str', 'list'];
if (~list.indexOf('my')) {
console.log('the `list` array contains \'my\'');
}
if (!~list.indexOf('number')) {
console.log('the `list` array does not contain \'number\'');
}
@yannbertrand
yannbertrand / angular-bullshit.js
Last active June 13, 2018 17:48
Bullshit code from Angular
$resource(a, b, {
getSomething: {
method: 'GET',
url: baseUrl + ':id' // work if you pass the `id` param in the parameters object
},
postSomething: {
method: 'POST',
url: baseUrl + ':id', // you need to add the next line to make it work for post requests (didn't try with other verbs)
params: { id: '@id' }
}
@yannbertrand
yannbertrand / Naming things in programming
Created January 7, 2016 13:38
Some advices to apply good names for your programming entities
See http://fr.slideshare.net/pirhilton/how-to-name-things-the-hardest-problem-in-programming by @hilton
Summary of naming things badly :
- meaningless: foo
- too general: data
- too short: a
- too long: text_correction_by_editor
- abbreviated: acc (id is the only acceptable abbreviation)
- vague: InvoiceManager
- wrong: order
@yannbertrand
yannbertrand / implode-explode.js
Last active April 6, 2017 13:36
How to implode/explode an array in JS?
// explode -> .split
console.log(['Hello', 'World'].join()) // ',' is optional
// → "Hello,World"
// implode -> .join
console.log('Hello,World'.split(','))
// → Array [ "Hello", "World" ]
@yannbertrand
yannbertrand / window-locations-tips.js
Last active August 29, 2015 14:25
Some window.location tips
// We are on page
// http://www.example.com:8080/search?q=devmo#test
console.log(window.location.href)
// → "http://www.example.com:8080/search?q=devmo#test"
console.log(window.location.origin)
// → "http://www.example.com:8080"
console.log(window.location.protocol)
@yannbertrand
yannbertrand / console-tips.js
Last active July 17, 2016 04:38
Some console tips
/**
* console.log
*/
console.log('Hello');
// → "Hello"
var hello = 'Hello';
console.log(hello);
// → "Hello"
@yannbertrand
yannbertrand / Preferences.sublime-settings
Last active August 29, 2015 14:24 — forked from benatkin/Global.sublime-settings
Hiding some folders from Sublime Text 3's Side Bar
// Place user-specific overrides in this file, to ensure they're preserved
// when upgrading
{
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"]
}