Skip to content

Instantly share code, notes, and snippets.

View kobus1998's full-sized avatar
😳
-10x programmer

Kobus kobus1998

😳
-10x programmer
View GitHub Profile
const scribble = require('scribbletune')
const _ = require('lodash')
function randomInt (min, max) {
return Math.floor((Math.random() * max) + min)
}
function createPattern () {
let choices = ['x', '_']
let pattern = ''
@kobus1998
kobus1998 / Player.js
Last active July 1, 2020 04:55
Jump animation with requestAnimationFrame
class Player {
constructor () {
// ctx, positions, dimensions, isJumping, jumpSpeed, fallSpeed etc...
}
jumpUp () {
this.isJumping = true
this.position.y -= this.jumpSpeed
this.jumpAnimationUp = requestAnimationFrame(this.jumpUp.bind(this)) // bind jumpUp to request animation frame
@kobus1998
kobus1998 / Field.php
Created November 3, 2017 16:39
PHP Database builder
<?php
namespace my\name\space;
class Field {
private $table; // parent table is Table class
public $type; // field type, i.e. varchar, string etc..
public $name; // field name
public $isNullable = false;
@kobus1998
kobus1998 / Index.js
Created December 11, 2017 10:23
Javascript observing
const observer = new Observer()
let u1 = new User({name: 'jan'}, observer)
let u2 = new User({name: 'piet'}, observer)
let u3 = new User({name: 'klaas'}, observer)
let u4 = new User({name: 'kees'}, observer)
u2.sendMessage('Hi everybody!')
// output:
@kobus1998
kobus1998 / Pipe.php
Last active December 22, 2017 12:31
PHP simple pipeline class
<?php
namespace App\Utill;
class Pipe {
/**
* @var Any return value of last function
*/
private $result = null;
@kobus1998
kobus1998 / Request.php
Created December 22, 2017 12:08
PHP curl request helper / utill
<?php
namespace App\Utill;
class Request
{
/**
* @var Object curl request
*/
@kobus1998
kobus1998 / Container.php
Last active December 22, 2017 15:25
Php manager container instances
<?php
namespace App\Utill;
class Container {
/**
* @var Array container instances
*/
public static $instances = [];
@kobus1998
kobus1998 / Best.php
Created January 3, 2018 14:20
Managing instance by using traits
<?php
/**
* Example class
*/
class Best
{
use Manager;
public $name;
@kobus1998
kobus1998 / lodash.hpp
Created January 8, 2018 10:23 — forked from quark-zju/lodash.hpp
Little C++ header inspired by Ruby and Lo-dash
// compile with -std=c++1y
#include <algorithm>
#include <functional>
#include <iterator>
#include <vector>
namespace LoDash {
using std::begin;
<?php
class Mapper
{
private $instance;
function __construct (string $type, string $method, array $data)
{
if ($type == 'post')
{