Skip to content

Instantly share code, notes, and snippets.

View maxparm's full-sized avatar

Maxime Parmentier maxparm

View GitHub Profile
@maxparm
maxparm / is-21-years-old.js
Created April 9, 2012 17:56
JS - Is 21 Years Old?
function is21YearsOld(date) {
var now = new Date();
var date = new Date(date);
var old = new Date(now.getFullYear()-21, now.getMonth(), now.getDate());
return date.getTime()<old.getTime();
}
@maxparm
maxparm / fold.html
Created May 23, 2012 00:17
CSS - 3D Accordion/Paper Fold Effect
<!doctype html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Css3 Fold Effect</title>
@maxparm
maxparm / test.js
Created July 26, 2011 22:14
JS - Boolean values in javascript conditions
// Boolean Value
console.log('===== Boolean Value!');
console.log( ( 1 ) ? 'true' : 'false' ); // true
console.log( ( '0' ) ? 'true' : 'false' ); // true
console.log( ( '1' ) ? 'true' : 'false' ); // true
console.log( ( [] ) ? 'true' : 'false' ); // true
console.log( ( {} ) ? 'true' : 'false' ); // true
console.log( ( '' ) ? 'true' : 'false' ); // false
console.log( ( 0 ) ? 'true' : 'false' ); // false
console.log( ( NaN ) ? 'true' : 'false' ); // false
@maxparm
maxparm / .htaccess
Created July 13, 2012 15:37
.htaccess with appropriate CORS header
<IfModule mod_rewrite.c>
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
Header add Access-Control-Allow-Headers: "Content-Type"
RewriteEngine on
RewriteBase /
</IfModule>
@maxparm
maxparm / Procfile
Created January 16, 2013 17:05
Django: serve static files on Heroku cedar stack 1) Make sure files are matching with following 2) Create a /static/ directory and add it to git (make sure it is added, this will trigger collect static command from heroku) 3) Make sure to have gunicorn in requirements.txt
web: python manage.py runserver 0.0.0.0:$PORT --noreload
@maxparm
maxparm / instagram.php
Created April 3, 2012 17:42
PHP - Request Instagram api with PHP/Curl
<?php
//Get data from instagram api
$hashtag = 'max';
//Query need client_id or access_token
$query = array(
'client_id' => '',
'count' => 3
);
$url = 'https://api.instagram.com/v1/tags/'.$hashtag.'/media/recent?'.http_build_query($query);
@maxparm
maxparm / jquery-input-number-filter.js
Created March 26, 2012 23:47
JS - jQuery Allow only numeric characters in HTML input
$(function(){
$('input[name="number"]').bind('keypress', function(e){
var keyCode = (e.which)?e.which:event.keyCode
return !(keyCode>31 && (keyCode<48 || keyCode>57));
});
});
@maxparm
maxparm / toggle-ajax-loading.css
Last active January 21, 2021 02:57
Javascript - Toggling a loading screen with jQuery ajax
.loading-container {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
display:none;
}
.loading-container:before {
position:absolute;
@maxparm
maxparm / bookmarklet.js
Created May 7, 2019 22:22
Bookmarklet for Jira to Github Issue
javascript:(function(){
var url = location.href;
var title = `${document.getElementById('key-val').innerText} ${document.getElementById('summary-val').innerText}`;
var description = document.getElementById('description-val').innerText;
body = `
### Description
[Jira](${location.href})
${description}
@maxparm
maxparm / terminal-upload-file-remote-server.txt
Created March 30, 2012 16:55
COMMAND - to upload file to remote server
scp example.txt username@server:/path/to/upload/