Skip to content

Instantly share code, notes, and snippets.

@yannbertrand
yannbertrand / Article.js
Created May 21, 2015 13:25
Example models
module.exports = {
attributes: {
title: {
type: 'text'
},
content: {
type: 'text'
},
@yannbertrand
yannbertrand / matches.json
Created May 21, 2015 13:30
2015 Rugby World Cup Fixtures
[
{
"matchNumber": 1,
"kickOff": "2015-09-18T20:00:00.000Z",
"pool": "A",
"teamA": "England",
"teamB": "Fiji",
"location": "Twickenham, London"
},
@yannbertrand
yannbertrand / json-stringify-tips.js
Last active August 29, 2015 14:24
JSON.stringify tips
var toto = {
foundation: 'Mozilla',
model: 'box',
week: 45,
transport: 'bus',
month: 7
};
JSON.stringify(toto);
// '{"foundation":"Mozilla","model":"box","week":45,"transport":"bus","month":7}'
@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"]
}
@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 / 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 / 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 / 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]
# 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
https://www.linux.com/community/blogs/133-general-linux/850945-setup-mutt-with-gmail-on-centos-and-ubuntu