Skip to content

Instantly share code, notes, and snippets.

View adyngom's full-sized avatar

Ady Ngom adyngom

View GitHub Profile
@adyngom
adyngom / theme_name_scripts.php
Last active July 9, 2016 07:04
Properly adding conditional styles ( IE 8 , IE 9 etc...) and scripts to your wordpress theme
<?php
/**
* Wordpress is @ 4.5.3
* https://developer.wordpress.org/reference/functions/wp_style_add_data/
* https://developer.wordpress.org/reference/functions/wp_script_add_data/
* no need to use global $wp_data
* add to your theme's functions.php file
* */
define('THEME_TEMPLATE_PATH', get_template_directory_uri());
@adyngom
adyngom / app.js
Created July 27, 2016 09:23
Dynamic Search Filtering in Angular JS Example
(function () {
'use strict';
angular
.module('va', [])
.filter('highlight', highlight)
.factory('query', query)
.controller('searchlist', searchList);
highlight.$inject = ['$sce'];
function highlight($sce) {
@adyngom
adyngom / fizzbuzz.html
Created January 27, 2017 03:18
FizzBuzz Challenge
<ul id="fizzbuzz">
</ul>
<script type="text/javascript" src="fizzbuzz.js"></script>
@adyngom
adyngom / flattened.js
Last active September 26, 2017 17:06
/**
* Write some code, that will flatten an array of arbitrarily nested arrays of integers into a
* flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
**/
/**
* forEach solution
**/
const FlatLinerFE = function(arr) {
let flatline = [];
@adyngom
adyngom / es6-int-classes-initial-code.js
Created September 6, 2017 21:07
es6-int-classes-initial-code
'use strict';
const Felidea = function() {
const bigCats = ['tiger','lion','jaguar', 'leopard', 'snow leopard'];
const midSize = ['clouded leopard', 'sunda clouded leopard'];
let species = Object.freeze([...bigCats, ...midSize]);
return species;
}
const Panthera = function(kind, name, options) {
// check if the kind belong to the species list
var findMissingNumber = function(arr) {
let size = arr.length;
console.log(size);
if(!size) {
return false;
}
// could sort the array first and get
// first and last index
// not sure which one would be faster
//let lower = Math.min.apply(null, arr);
String.prototype.isPalindrome = function() {
let specialChars = /[`~!@#$%^&*()_|+\-=?;’—:'",.<>\{\}\[\]\\\/]/gi;
let prepped = this.replace(specialChars, '').replace(/\s/g, '').toLowerCase();
return ( prepped === prepped.split('').reverse().join('') )
};
console.log("Matam", "Matam".isPalindrome()); // true
console.log("racecar", "racecar".isPalindrome()); // true
console.log("race car", "race car".isPalindrome()); // true
function solution(N) {
const nope = 0;
if(!N) return nope;
let bin = (N >>> 0).toString(2);
let binLength = bin.length;
function solution(A) {
return A.reduce( (a,c) => a ^= c ); // xor operator is sexy :)
}
var barr = [10,10, 4, 3, 4, 6, 8, 8, 6];
console.log(solution(barr)); // returns 3;
function solution(X, Y, D) {
// write your code in JavaScript (Node.js 6.4.0)
if( D <= 0 || Y <= X ) return 0;
var J = Math.ceil( ( Y - X) / D );
return J;
}
console.log( solution(10, 85, 30) ); // 3