Skip to content

Instantly share code, notes, and snippets.

🤓
Nerding Out

Negar negarjf

🤓
Nerding Out
Block or report user

Report or block negarjf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Stack.js
class Stack{
constructor(){
this.top = null;
this.size = 0;
}
get isEmpty(){
return this.top === null;
}
View Queue.js
class Queue {
constructor(){
this.head = null;
this.tail = null;
this.size = 0;
}
get length(){
return this.size;
}
View DynamicArray.js
class DynamicArray{
constructor(capacity){
this.arr = [];
this.capacity = capacity;
this.length = 0;
for(let i = 0; i < capacity; i++){
this.arr[i] = null;
}
View circularQueue.js
class circularQueue{
constructor(max){
this.array = [];
this.max= max;
this.length = 0;
View findPeakElement.js
/**
* Find a Peak in an Array
* @param {number[]} nums
* @return {number}
*/
var findPeakElement = function(nums) {
let l = nums.length - 1;
let half = Math.floor(l / 2);
View bubble-sort.js
let testArray = [10, 25, 25, 12, 22, 11, 90];
console.log(sort(testArray));
function sort(array){
let length = array.length;
for(let i = 0; i < length; i++ ){
@negarjf
negarjf / .htaccess
Created Feb 17, 2019
.htaccess config for local cross origin problem
View .htaccess
# .htaccess config for local cross origin problem
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, cache-control"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
@negarjf
negarjf / string-id-generator.js
Last active Aug 20, 2019
Generating unique random strings with optional prefix and postfix.
View string-id-generator.js
/**
* Generates random string id
*
* @param prefix
* @param postfix
* @returns {string}
*/
function generateId(prefix, postfix) {
prefix = prefix || "";
postfix = postfix || "";
@negarjf
negarjf / text-color-detector.js
Created Sep 14, 2018
Auto Text Color Detector
View text-color-detector.js
// Converts color code to RGB
//====================================
function colorCodeToRGB(colorCode){
var c;
var rgbaValidation = (/([R][G][B][A]?[(]\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])(\s*,\s*((0\.[0-9]{1})|(1\.0)|(1)))?[)])/i.test(colorCode)) ;
var hexValidation = (/^#([A-Fa-f0-9]{3}){1,2}$/.test(colorCode));
if(hexValidation){
c= colorCode.substring(1).split('');
You can’t perform that action at this time.