Skip to content

Instantly share code, notes, and snippets.

View nielk's full-sized avatar
🦊

Alexandre Oger nielk

🦊
View GitHub Profile

Deploying a dist folder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by yeoman).

Step 2

@nielk
nielk / gist:6350399
Last active December 21, 2015 18:49
node.js basic server
var http = require('http');
var fs = require('fs');
http.createServer(function(request, response) {
response.writeHead(200,{
'Content-Type':'text/html'
});
fs.readFile('index.html',function(err,contents){
/* response.write(contents);
response.end(); */
@nielk
nielk / gist:6379571
Created August 29, 2013 15:30
content protected with password on drupal
<?php
// Add this into PHP code
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if (!isset($_SERVER['PHP_AUTH_USER'])
|| $username != "qwerty" || $password != "qwerty") {
header('WWW-Authenticate: Basic realm="Please Login"');
header('HTTP/1.0 401 Unauthorized');
print 'Sorry, incorrect password or username.';
@nielk
nielk / app.js
Last active December 22, 2015 00:28
A simple horizontal content slider with 2 slides
$(document).ready(function() {
$('.slide-01').click(function() {
$(this).toggleClass('hide-section');
$(this).parent().find('.slide-02').toggleClass('show-section');
});
$('.slide-02').click(function() {
$(this).parent().find('.slide-01').toggleClass('hide-section');
$(this).toggleClass('show-section');
});
@nielk
nielk / gist:6495997
Created September 9, 2013 14:02
Bootstrap container without margin
body {
padding: 0;
}
.container {
background-color: yellow;
min-width: 100%;
padding: 0;
}
@nielk
nielk / gist:6615163
Created September 18, 2013 20:27
an example of regex with variable
var tmp = '.txt'
var ext = new RegExp("\\."+tmp+'$') // recherche extension de fichier
@nielk
nielk / index.html
Last active December 24, 2015 14:09
Bootstrap/angularjs Form with validation
<!doctype html>
<html ng-app="myApp">
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="myCtrl">
@nielk
nielk / main.css
Created October 10, 2013 18:48
css vertical and horizontal centered element
.centered {
width: 100px;
height: 100px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
background-color: blue;
@nielk
nielk / infinite-scroll-jquery-angularjs.html
Last active December 25, 2015 14:39
angularjs ng-repeat infinite scroll with jquery
<div ng-app="app" ng-controller="listCtrl" id="listr" ng-init="count=10">
<div ng-repeat="chose in choses | orderBy:'date':true | limitTo:count" class="choses">
<section class="inner">
<div class="row container-chose">
<div class="col-sm-2 col-md-2 col-lg-2" ng-class-odd="'odd'" ng-class-even="'even'">
<img src="./uploads/{{chose.image}}" class="img-circle chose" />
</div>
<div class="col-sm-5 col-md-5 col-lg-5" ng-class-odd="'even'" ng-class-even="'odd'">
<h2>{{chose.title}} par {{chose.author}}</h2>
<p>{{chose.content}}</p>
@nielk
nielk / gist:7067612
Last active December 26, 2015 00:58
avoid JSLint errors
(function () {
'use strict';
/*jslint evil: true */
/*jslint browser:true */
var person, anotherPerson; // var statements at begin
/*
My code here
*/
}());