Skip to content

Instantly share code, notes, and snippets.

View EpokK's full-sized avatar

Richard EpokK

View GitHub Profile
@EpokK
EpokK / manual.js
Last active August 29, 2015 14:02
Manual lowercase / uppercase
String.prototype.manualLowercase = function(s) {
return (typeof s === 'string') ? s.replace(/[A-Z]/g, function (ch) {
return String.fromCharCode(ch.charCodeAt(0) | 32)
}) : s;
};
String.prototype.manualUppercase = function (s) {
return (typeof s === 'string') ? s.replace(/[a-z]/g, function (ch) {
return String.fromCharCode(ch.charCodeAt(0) & ~32)
}) : s;
@EpokK
EpokK / inject.js
Created June 26, 2014 14:27
Realiser une injection dans les routes d'AnuglarJS
var resolver = {
crew: function ($q, $route, $timeout, starTrekResource) {
//...
}
}
resolver.crew.$inject = ['$q','$route, '$timeout',' 'starTrekResource'];
$routeProvider.when("/:starship", {
templateUrl:"partials/starship.html",
@EpokK
EpokK / ng-really.js
Created July 18, 2014 07:07
ng-really? An AngularJS directive that creates a confirmation dialog for an action.
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Really?" ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
@EpokK
EpokK / dnd.js
Created November 24, 2014 14:29
dnd js natif with angularJS
var app = angular.module('dragDrop', []);
app.directive('draggable', function() {
return function(scope, element) {
// this gives us the native JS object
var el = element[0];
el.draggable = true;
el.addEventListener(
@EpokK
EpokK / vanilla.js
Last active August 29, 2015 14:13
Usefull Vanilla functions
var isMobile = function() {
return !!navigator.userAgent.match(/Android|BlackBerry|BB10; Touch|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
};
Array.prototype.clone = function () {
return Array.prototype.slice.call(this, 0);
};
Array.prototype.clear = function() {
this.length = 0;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<div class="steps">
<a href="" class="step step1">1</a>
<div class="line line1"></div>
<a href="" class="step step2">2</a>
<div class="line line2"></div>
@EpokK
EpokK / focus.js
Created March 5, 2015 08:37
Move Caret to End of Input or Textarea
var focus = function(input) {
if (typeof input.selectionStart === "number") {
input.selectionStart = input.selectionEnd = input.value.length;
} else if (typeof input.createTextRange !== "undefined") {
input.focus();
var range = input.createTextRange();
range.collapse(false);
range.select();
}
};
@EpokK
EpokK / unsafe.filter.js
Created March 23, 2015 10:13
trustAsHtml filter
app.filter('unsafe', function($sce) {
return $sce.trustAsHtml;
});

Keybase proof

I hereby claim:

  • I am epokk on github.
  • I am epokk (https://keybase.io/epokk) on keybase.
  • I have a public key whose fingerprint is 9622 0F0C EF0C 7089 FE61 FDAD 925A DE16 89E0 2EC0

To claim this, I am signing this object: