Skip to content

Instantly share code, notes, and snippets.

View Kjaer's full-sized avatar
👷‍♂️
Code Janitor

Halil Kayer Kjaer

👷‍♂️
Code Janitor
View GitHub Profile
@Kjaer
Kjaer / app.js
Last active August 29, 2015 14:09
Angular.js Divide List with ng-repeat
var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl', function ($scope) {
$scope.parts = [{"Id":7204, "Name":"Air Cleaner", "ProductCount":3452},
{"Id":7205, "Name":"Battery", "ProductCount":76},
{"Id":7206, "Name":"Choke", "ProductCount":342},
{"Id":7207, "Name":"Clutch Lever", "ProductCount":98},
{"Id":7208, "Name":"Crankcase Cover", "ProductCount":0},
{"Id":7209, "Name":"Crash Bar", "ProductCount":456},
{"Id":7210, "Name":"Cylinder", "ProductCount":184},
(function (w, d, s) {
function go() {
var js,
fjs = d.getElementsByTagName(s)[0],
load = function (url, id) {
if (d.getElementById(id)) { return; }
js = d.createElement(s);
js.src = url;
js.id = id;
fjs.parentNode.insertBefore(js, fjs);
This is the javascript regular expression to check password meet the reqirements.
Here it is :
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[$-/ | :-? | {-~ | ! | @ | # | " | ^ | _ |` | \[ | \]])[a-zA-Z0-9$-/:-?{-~!@#"^_`\[\]]{8,16}/g
(?=.*[a-z]) means should include lowercase letter
(?=.*[A-Z]) means should include uppercase letter
(?=.*[0-9]) means should include number
(?=.*[$-/ | :-? | {-~ | ! | @ | # | " | ^ | _ |` | \[ | \]]) means should include symbol
@Kjaer
Kjaer / filter.js
Created November 19, 2017 06:54 — forked from vpalos/filter.js
JS: A simple search function designed for filtering large lists of strings.
/**
* Demo: http://vpalos.com/sandbox/filter.js/
*
* A generic search algorithm designed for filtering (very) large lists of strings; when an input string
* contains all the parts (words or characters; whitespace is ignored) of the query, spread-out over the text
* then the string is considered to be a match. It works with the way internet browsers (e.g. Firefox, Google
* Chrome) filter address-bar suggestions on user input. It is also quite fast; on my i7 laptop, filtering
* 1) a list of ~23000 items takes around 50ms (yes, milliseconds!);
* 2) a list of ~1 million text items took under 1 second.
* It works both in NodeJS as well as in browser environments (so far I only tested FF and GC).
@Kjaer
Kjaer / HashTable.js
Created November 19, 2017 20:21 — forked from alexhawkins/HashTable.js
Correct Implementation of a Hash Table in JavaScript
var HashTable = function() {
this._storage = [];
this._count = 0;
this._limit = 8;
}
HashTable.prototype.insert = function(key, value) {
//create an index for our storage location by passing it through our hashing function
var index = this.hashFunc(key, this._limit);
@Kjaer
Kjaer / Remote_responsejson
Last active December 15, 2017 08:58
Data Model Example
"questions": [
{
"question_type": "multiple-choice",
"identifier": "ac9835eb-9efa-4cce-9e35-09987d32e6c8",
"headline": "Multiple Choice Question Sentence 1",
"description": null,
"required": false,
"multiple": true,
"choices": [
{
@Kjaer
Kjaer / revert-a-commit.md
Created March 7, 2019 13:23 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@Kjaer
Kjaer / algo.js
Last active April 8, 2019 10:23
find longest same char
/*
Algorithmic task
Given a string of length 1048576,
find the position of the longest substring made from identical characters.
It is guaranteed that there is only one such substring and its length is 8192.
You are not allowed to peek inside the string, however you can call an external
function "getMaxLength(int startPosition, int endPosition)" which will return
the longest number of identical consecutive characters found within the interval.
@Kjaer
Kjaer / any_view.html
Created November 13, 2017 07:36
knockout String Template solution.
<!-- plyr binding usage -->
<div class="video-player-container" data-bind="plyr:{videos:playerData.videos,cover:playerData.cover, instance:playerData.instance}"></div>
@Kjaer
Kjaer / missing_integer.js
Created April 13, 2019 15:51
Missing Integer
/**
* MISSING INTEGER
* ---
* Write a function:
* function solution(A);
* that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
* For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
* Given A = [1, 2, 3], the function should return 4.
* Given A = [−1, −3], the function should return 1.
*