Skip to content

Instantly share code, notes, and snippets.

View ken-master's full-sized avatar

Ken ken-master

View GitHub Profile
@ken-master
ken-master / promise.js
Created August 8, 2018 09:08
Async Await with promise inside loop
(async () => {
for (let i = 0; i < 100; i++) {
await something(i)
await delay(i);
}
console.log("LOOP FINISHED");
})();
@ken-master
ken-master / group_concat.sql
Created February 21, 2017 07:13
sample of group_concat
select sku, group_concat(itemid) as itemids
from rfq_pipeline
left join candidate_skus using (sku)
group by sku limit 200
@ken-master
ken-master / sutdents.php
Created February 8, 2017 23:37
some codility challenge
<?php
function solution($A) {
// write your code in PHP7.0
$a = 0;
$c = count($A);
for( $i = 0; $i <= $c; $i++ ){
if( $A[$i] <= ( current($A) + 1 ) ){
$a++;
}
}
@ken-master
ken-master / cs.go
Created January 12, 2017 00:17
CSGO override command
exec gamemode_casual
changelevel de_dust2
bot_kick
mp_forcecamera 1
mp_freezetime 10
mp_maxrounds 100
mp_roundtime 1.92
@ken-master
ken-master / gist:fcd5aa8fd39fba6577b3ed8e6deec54a
Created April 12, 2016 05:43 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@ken-master
ken-master / container.php
Last active April 6, 2016 07:24
PHP Dependency Injection - Quick and Dirty version
<?php namespace Src\Cache;
/**
* Dependency Injection Container
*/
class Container
{
@ken-master
ken-master / fuzzbuzzwoof.php
Created February 23, 2016 14:35
Fuzz,Buzz & Woof
<?php
function solution($N) {
//asuming $N is a range of numbers integr
for ($i = 1; $i <= $N; $i++){
if( $i%3 == 0 && $i%5 == 0 && $i%7 == 0 ){
echo "FizzBuzzWoof\n";
}elseif( $i%3 == 0 && $i%5 == 0){
echo "FizzBuzz\n";
}elseif($i%3 == 0 && $i%7 == 0){
@ken-master
ken-master / peak.php
Created February 23, 2016 14:34
Peak
<?php
function solution($A) {
$i = 0;
$k = 0;
$arr_count = count($A);
for( $j = 0;$j<=$arr_count;$j++ ){
$k = $A[$i];
@ken-master
ken-master / tictactoe.html
Last active February 15, 2016 14:51
Tic Tac Toe using javascript (jquery)
<!DOCTYPE html>
<html>
<head>
<style>
tr > td {
height: 30px;
width:30px;
align: center;
@ken-master
ken-master / diagonal_array_summation.php
Created February 12, 2016 07:27
diagonal array summation
<?php
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$n);
$a = array();
for($a_i = 0; $a_i < $n; $a_i++) {
$a_temp = fgets($handle);
$a[] = explode(" ",$a_temp);
array_walk($a[$a_i],'intval');
}