Skip to content

Instantly share code, notes, and snippets.

View maxailloud's full-sized avatar

Maxime Ailloud maxailloud

View GitHub Profile
@maxailloud
maxailloud / post-merge
Created March 2, 2017 13:25 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@maxailloud
maxailloud / style.scss
Created March 2, 2017 08:59
Angular Material 2 theming
@import '~@angular/material/core/theming/all-theme';
@include mat-core();
$primary: mat-palette($mat-blue);
$accent: mat-palette($mat-deep-orange, A200, A100, A400);
$theme: mat-light-theme($primary, $accent);
@include angular-material-theme($theme);
@maxailloud
maxailloud / preview-upload-image.js
Created October 31, 2013 13:52
Show dynamically image before upload it
$('upload_form_field').on('change', function(){
var input = this;
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (event) {
console.log(event.target.result);
};
reader.readAsDataURL(input.files[0]);
For many git-based projects, submodules are useful in avoiding duplicate work and easing utility library updates. There are times, however, when a submodule needs to be removed from a project. Submodules aren't removed with git rm submoduledir, they must be removed in a more tedious, manual fashion. There are many unclear explanations of how to remove a submodule but I found one on Stack Overflow that's concise, so I thought I'd share it. The steps are as follows:
Delete the relevant section from the .gitmodules file. The section would look similar to:
[submodule "vendor"]
path = vendor
url = git://github.com/some-user/some-repo.git
Stage the .gitmodules changes via command line using:git add .gitmodules
Delete the relevant section from .git/config, which will look like:
[submodule "vendor"]
url = git://github.com/some-user/some-repo.git
var loading = false;
$(window).scroll(function(){
if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){
if(loading == false){
loading = true;
$('#loadingbar').css("display","block");
$.get("load.php?start="+$('#loaded_max').val(), function(loaded){
$('body').append(loaded);
$('#loaded_max').val(parseInt($('#loaded_max').val())+50);
$('#loadingbar').css("display","none");
// HTML:
// <h1 id="anchor">Lorem Ipsum</h1>
// <p><a href="#anchor" class="topLink">Back to Top</a></p>
$(document).ready(function() {
$("a.topLink").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
@maxailloud
maxailloud / file.js
Created June 12, 2013 10:50
JQuery file base template
(function($) {
"use strict";
$(function() {
//put your code here
});
})(jQuery);
@maxailloud
maxailloud / pr.md
Created August 14, 2012 08:51 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: