Skip to content

Instantly share code, notes, and snippets.

View jawdatls's full-sized avatar
💭
I may be slow to respond.

Jawdat Sobh jawdatls

💭
I may be slow to respond.
View GitHub Profile
@jawdatls
jawdatls / TimeCount.html
Created May 11, 2015 08:19
Time Count Up
<div class="counter">
<strong class="h">0</strong>
<span>:</span>
<strong class="m">0</strong>
<span>:</span>
<strong class="s">0</strong>
</div>
<script type="text/javascript">
$(document).ready(function(){
var time = (60 * 60 + 60 * 59 + 55); // start from 1 hour and 59 minutes and 55 seconds
@jawdatls
jawdatls / Less.xml
Created May 11, 2015 08:25
Less style for notepad++
<NotepadPlus>
<UserLang name="LESS++" ext="less" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="yes" Keywords4="no" Keywords5="yes" Keywords6="no" Keywords7="yes" Keywords8="yes" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"/>
<Keywords name="Numbers, prefix2">#</Keywords>
@jawdatls
jawdatls / keysToValuesList.php
Created May 11, 2015 08:27
convert 1,2,3 keys to values
<?php
echo implode(', ',array_intersect_key(array(0=>'guest',1=>'user',2=>'admin'),array_flip(explode(',',$user->role))));
?>
@jawdatls
jawdatls / sort.html
Created May 11, 2015 08:29
Sort DOM Elements with jQuery
<ul class="js-people">
<li data-name="John Doe">Mr. John Doe</li>
<li data-name="Trent Richardson">Mr. Trent Richardson</li>
<li data-name="Cindy Smith">Ms. Cindy Smith</li>
<li data-name="Bill Williams">Mr. Bill Williams</li>
<li data-name="Jane Doe">Mrs. Jane Doe</li>
</ul>
<script>
$(document).ready(function(){
var $people = $('ul.js-people'),
@jawdatls
jawdatls / camera.html
Created May 11, 2015 08:30
Html5 Camera
<video id="video" width="640" height="480" autoplay></video>
<button id="snap" class="sexyButton">Snap Photo</button>
<canvas id="canvas" width="640" height="480"></canvas>
<script>
/* Put event listeners into place */
window.addEventListener("DOMContentLoaded", function() {
// Grab elements, create settings, etc.
var canvas = document.getElementById("canvas"),
@jawdatls
jawdatls / clickOutsideDivHide.js
Created May 11, 2015 08:31
Hide div on click outside
$(document).mouseup(function (e)
{
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
@jawdatls
jawdatls / Calendar.php
Created May 11, 2015 08:32
Calendar Helpfull
<?php
class Calendar {
static $now = 0;
function __construct() {
Calendar::$now = time();
}
function years($start, $end) {
@jawdatls
jawdatls / Password.php
Created May 11, 2015 08:33
Php Class Password
<?php
class Password
{
const ALPHANUMERIC = 0;
const NUMBERS_ONLY = 1;
const ALPHABETIC_ONLY = 2;
private $password;
private $salt;
private $hash;
@jawdatls
jawdatls / insertAtCaret.js
Created May 11, 2015 08:34
jQuery insert text at caret
$.fn.extend({
insertAtCaret: function(myValue) {
var obj;
if( typeof this[0].name !='undefined' ) obj = this[0];
else obj = this;
if ($.browser.msie) {
obj.focus();
sel = document.selection.createRange();
sel.text = myValue;
obj.focus();
@jawdatls
jawdatls / getCursorPosition.js
Created May 11, 2015 08:35
jQuery get cursor position
(function ($, undefined) {
$.fn.getCursorPosition = function() {
var el = $(this).get(0);
var pos = 0;
if('selectionStart' in el) {
pos = el.selectionStart;
} else if('selection' in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;