Skip to content

Instantly share code, notes, and snippets.

View kigold's full-sized avatar

Kingsley Ekoh-Ordan kigold

  • Lagos, Nigeria
View GitHub Profile
@kigold
kigold / file_rename.js
Created July 15, 2017 14:56
Renames all files in a folder with Node/Javascript
var fs = require( 'fs' );
var path = require( 'path' );
// In newer Node.js versions where process is already global this isn't necessary.
var process = require( "process" );
var folder = path.join(__dirname,"/folder_name");
console.log(folder);
// Loop through all the files in the temp directory
fs.readdir( folder, function( err, files ) {
@kigold
kigold / Wordpress Stat Counter
Last active April 3, 2017 12:08
Wordpress js script to get user field anf then user the value to change the the data-counter-value of a stats counter
//Select Stat counter element
var y = document.querySelectorAll('.credit_value [data-counter-value="2000000"]');
//Get user income from wp member field if id user_income
var user = document.querySelectorAll('#user_income .wpb_wrapper')[0];
var user_income = user.innerHTML;
var income = user_income.split(" ")[0];
income = income.replace(',', '');
income = Number(income) - 1;
console.log(income);
///set the data-counter-value attribute of the stat counter to the user monthly income
@kigold
kigold / bin_conv.py
Last active September 19, 2016 16:13
def binary_converter(n):
if type(n) == str or n > 255 or n < 0:
print 'Invalid input'
return 'Invalid input'
if n == 0:
return '0'
numb = int(n)
result = []
while numb != 0:
result.append(numb%2)
def chkSqe(a1, a2):
'''
this method receive two array on characters, a1, and a2
it checks array a1 is the sequence of character in a2 exist
in the order, and returns true is so, or false if not
Args: a1: array of characters
a2: array of characters
Return: Boolean
'''
char_to_chk = 0
function solution(A) {
var length = A.length;
if (length == 1){
return 0;
}
if (length < 1){
return -1;
}
if (A.slice(1).reduce((a,b) => a+b) === 0){
return 0