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 / rAF.js
Created March 13, 2013 09:38 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@netgfx
netgfx / gist:f33a49d7e95c42a13873
Created February 8, 2016 12:10 — forked from Katafalkas/gist:eb5e840df1ace981c359
Swift UITableViewCell custom subclass simple Chat Bubble
class Cell: UITableViewCell {
override func drawRect(rect: CGRect) {
var bubbleSpace = CGRectMake(20.0, self.bounds.origin.y, self.bounds.width - 20, self.bounds.height)
let bubblePath1 = UIBezierPath(roundedRect: bubbleSpace, byRoundingCorners: .TopLeft | .TopRight | .BottomRight, cornerRadii: CGSize(width: 20.0, height: 20.0))
let bubblePath = UIBezierPath(roundedRect: bubbleSpace, cornerRadius: 20.0)
UIColor.greenColor().setStroke()
UIColor.greenColor().setFill()
@netgfx
netgfx / CoreGraphics+AspectRatio.swift
Created May 28, 2016 10:21 — forked from jkosoy/CoreGraphics+AspectRatio.swift
Calculating for different device Aspect Ratios, used in Melody Jams
//
// CoreGraphics+AspectRatio.swift
// EmptySpriteKitGame
//
// Created by Jamie Kosoy on 11/6/15.
// Copyright © 2015 Arbitrary. All rights reserved.
//
import UIKit
import Foundation
@netgfx
netgfx / doBackgroundTask.swift
Created June 2, 2016 16:56 — forked from kristopherjohnson/doBackgroundTask.swift
Swift helper function for invoking a function in the background and then handling its result on the main thread
import Foundation
/// Execute a function on a background thread and then handle result
/// in main thread.
func doBackgroundTask<Params, Result>(
params: Params,
backgroundTask: (Params) -> Result,
onComplete: (Result) -> ())
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
@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 / 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 {
@netgfx
netgfx / firebase_player_assignment.js
Created December 17, 2017 13:42 — forked from anantn/firebase_player_assignment.js
Firebase: Assigning players in a multiplayer game. This snippet assigns you a spot in a game if the game isn't full yet.
function go() {
var userId = prompt('Username?', 'Guest');
// Consider adding '/<unique id>' if you have multiple games.
var gameRef = new Firebase(GAME_LOCATION);
assignPlayerNumberAndPlayGame(userId, gameRef);
};
// The maximum number of players. If there are already
// NUM_PLAYERS assigned, users won't be able to join the game.
var NUM_PLAYERS = 4;
@netgfx
netgfx / Simple Ajax Login Form.php
Created May 11, 2018 17:20 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">