Skip to content

Instantly share code, notes, and snippets.

View netgfx's full-sized avatar
💻
Working...

Michael Dobekidis netgfx

💻
Working...
View GitHub Profile
@netgfx
netgfx / random point between two points
Created June 10, 2016 08:31
random point between two points
var rand = Math.random;
var sin = Math.sin;
var cos = Math.cos;
var PI = Math.PI;
var TWO_PI = PI * 2;
function randomPoint(min, max) {
//generate a random distance between min and max
var dist = rand() * (max - min) + min;
@netgfx
netgfx / whatsapp-image-compression
Created August 1, 2016 18:43 — forked from akshay1188/whatsapp-image-compression
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@netgfx
netgfx / StateMachine.swift
Created December 21, 2016 17:29 — forked from jemmons/StateMachine.swift
A Simple Swift State Machine
import Foundation
class StateMachine<P:StateMachineDelegateProtocol>{
private unowned let delegate:P
private var _state:P.StateType{
didSet{
delegate.didTransitionFrom(oldValue, to:_state)
}
}
@netgfx
netgfx / gist:6ffcc77982db2bcabcdd80b7e11c86d0
Last active July 20, 2017 13:38
RandomBooleanBalancer
// from http://sbcgamesdev.blogspot.gr/2017/01/phaser-tutorial-how-to-balance-random.html
// converted to JS
// all rights reserved to Tomáš Rychnovský
var RandomBooleanBalancer = function(balancer) {
var _rnd = new Phaser.RandomDataGenerator([0,1]);
var _lbound;
var _ubound;
var _currentBalance;
### Keybase proof
I hereby claim:
* I am netgfx on github.
* I am netgfx (https://keybase.io/netgfx) on keybase.
* I have a public key ASBSUuqyWMZXfYNFGy8LPjjsEW-m0MgZXIUJet86AtdEDwo
To claim this, I am signing this object:
@netgfx
netgfx / Glow.js
Created March 23, 2017 15:23 — forked from MatthewBarker/Glow.js
Phaser glow filter
/*jslint white: true*/
/*global Phaser*/
/**
* Defines a glow filter for Web GL.
* @module
*/
Phaser.Filter.Glow = function (game) {
'use strict';
@netgfx
netgfx / JSONStringify.swift
Created April 24, 2017 17:08 — forked from santoshrajan/JSONStringify.swift
JSON Stringify in Swift
// Author - Santosh Rajan
import Foundation
let jsonObject: [AnyObject] = [
["name": "John", "age": 21],
["name": "Bob", "age": 35],
]
func JSONStringify(value: AnyObject, prettyPrinted: Bool = false) -> String {
var FirebaseAPI = FirebaseAPI || {};
FirebaseAPI = {
currentDB: {},
signInUser: function(loginMail, password) {
window.console.log("trying to login");
//Show User Name on Main menu screen
//////////////////////////////////////////////////////////////
@netgfx
netgfx / gist:5057b052ec49077800a5be33b1bbbbc8
Last active October 6, 2019 06:02
Pattern find in String solution
/**
The cake is round, and decorated with M&Ms in a circle around the edge. But while the rest of the cake is uniform, the M&Ms are not: there are multiple colors, and every minion must get exactly the same sequence of M&Ms. Commander Lambda hates waste and will not tolerate any leftovers, so you also want to make sure you can serve the entire cake.
To help you best cut the cake, you have turned the sequence of colors of the M&Ms on the cake into a string: each possible letter (between a and z) corresponds to a unique color, and the sequence of M&Ms is given clockwise (the decorations form a circle around the outer edge of the cake).
Write a function called answer(s) that, given a non-empty string less than 200 characters in length describing the sequence of M&Ms, returns the maximum number of equal parts that can be cut from the cake without leaving any leftovers.
**/
var pattern = "aaabbbcccddd"; //"abccbaabccba"; //"AZAZZZZAZAZZZZ"; //"aaaaabaaaaab"; //"abcabcabcabc"; //"AABBCCAABBCC";//"AZAZZZZAZAZZZZ
@netgfx
netgfx / pattern.java
Last active September 25, 2017 10:57
Pattern find algorith in Java
import java.lang.Math; // headers MUST be above the first class
import java.util.Arrays;
// one class needs to have a main() method
public class HelloWorld
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{