Skip to content

Instantly share code, notes, and snippets.

View weburnit's full-sized avatar
🏠
Working from home

Paul Aan weburnit

🏠
Working from home
View GitHub Profile
@weburnit
weburnit / Delegation.php
Last active October 9, 2015 04:58
Delegation
<?php
class OfficeDelegation implement BackupPowerDelegateInteface, PrinterDelegateInterface
{
public function duringOfficeLogic()
{
if($this->powerIsOff()){
$backupPower = new BackupPowerHandler();
$backupPower->setDelegate($this);
<?php
interface BackupPowerDelegateInteface
public function successTurnonPowerBackup();
public function successTurnonPowerBackup();
}
<?php
class ApplicationEngine
{
/**
* @var InterpreterInterface[]
*/
private $interpreters = [];
@weburnit
weburnit / starwar.js
Last active February 10, 2017 05:59
Starwar Challenge
function standardDeviation(values) {
var avg = average(values);
var squareDiffs = values.map(function (value) {
var diff = value - avg;
var sqrDiff = diff * diff;
return sqrDiff;
});
@weburnit
weburnit / StarWar-challenge.js
Created February 10, 2017 05:52
Star War Challenge - Jedi vs Sith
/*
# StarWar Challenge
## Summary:
The Sith have sent Lord Malice to find the last standing Jedi temple on an unknown planet.
We need to find what planet it is on before he does.
## Intel:
@weburnit
weburnit / Wizeline.php
Last active February 14, 2017 09:21
Wizeline Test in PHP
<?php
class Wizeline
{
private $range;
public function __construct(int $range)
{
$this->range = $range;
}
public function printNumbers(int $numbers = null)
@weburnit
weburnit / Wizeline.py
Last active February 14, 2017 09:03
Wizeline Test in Python
class Wizeline(object):
def printNumbers(self, rangeNumber):
for number in range(1, rangeNumber):
self.printNumber(number)
def printNumber(self, number):
mod = self.getMod(number)
result = {
'15': lambda x: 'WizeLine',
'5': lambda x: 'Line',
'3': lambda x: 'Wize',
@weburnit
weburnit / install_node.sh
Created January 29, 2018 15:16
GobearJS
brew install nodejs
npm install -g yarn
yarn add puppeteer
# save this content to file gobear.js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
@weburnit
weburnit / WebServer.java
Created November 20, 2018 17:26
WebServer.java
import java.io.*;
import java.net.*;
import java.util.ArrayList;
class WebServer {
// this is the port the web server listens on
private static final int PORT_NUMBER = 8080;
// main entry point for the application
public static void main(String args[]) {
@weburnit
weburnit / historio.py
Last active January 20, 2019 09:08
Historio
from historio import client
client.historio(server='grpc_address', port=5505)
def somewhere_else_in_your_application():
user = get_current_user() #Get current user
assignment = DynamoDBModel() #your source model
#time to push
client.historio().push(source='assignment', source_id=assignment.id, user_id=user.id, data=model)