Skip to content

Instantly share code, notes, and snippets.

@phpedinei
phpedinei / bitly.js
Created February 17, 2019 15:04 — forked from takuya/bitly.js
(function(long_url,callback){
bi = new URL("https://api-ssl.bitly.com/v3/shorten?");
var params = [
"login=YOUR_USER_ID",
"domain=j.mp",
"apiKey=YOUR_API_KEY",
"longUrl="+ encodeURIComponent(long_url)
]
bi.search = "?"+params.join('&')
var xhr = new XMLHttpRequest();
<?php
/**
* The admin-specific functionality of the plugin.
*
* @link bruno.briante.net
* @since 1.0.0
*
* @package Firebase_Bridge
* @subpackage Firebase_Bridge/admin
*/
@phpedinei
phpedinei / gist:6b2b380116744e2d53d27f0d63b43269
Created February 9, 2017 03:15 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@phpedinei
phpedinei / better-nodejs-require-paths.md
Created May 25, 2016 11:32 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@phpedinei
phpedinei / mathlib.lua
Created May 7, 2016 04:50 — forked from HoraceBury/_mathlib.lua
Mathematics functions, including trigonometry. The main file demonstrates the use of the various maths extension functions available in the library.
-- mathlib.lua
--[[
Maths extension library for use in Corona SDK by Matthew Webster.
All work derived from referenced sources.
Many of these functions are useful for trigonometry and geometry because they have developed for use within graphical user interfaces.
Much of these are useful when building physics games
twitter: @horacebury
blog: http://springboardpillow.blogspot.co.uk/2012/04/sample-code.html
@phpedinei
phpedinei / functions.lua
Created May 7, 2016 04:34
Corona SDK/lua functions that I've collected or created over the last couple of years. Sources are either stackoverflow, corona SDK forums or my head. I end up reusing these all the time
-- Distance between two coordinates
function distance( x1, y1, x2, y2 )
local dx = x1 - x2
local dy = y1 - y2
return math.sqrt ( dx * dx + dy * dy )
end
-- Return a section of a table
function cullTable(t,start,last)
@phpedinei
phpedinei / collision_manager.lua
Created May 7, 2016 04:32
A simple collision manager without uses of physics library to use with Corona SDK
local INITIAL_SIZE = 1
local action
local collisionActionToClear
local objects = {}
local throttle = {}
local size = INITIAL_SIZE
local function _clearFields()
size = INITIAL_SIZE
@phpedinei
phpedinei / download.lua
Created May 7, 2016 04:27 — forked from michael714/download.lua
Dropbox REST API module for Corona SDK
-- download.lua by Michael Weingarden May 2014
local dropbox = require("dropboxModule")
local widget = require( "widget" )
-- Load the relevant LuaSocket modules (no additional files required for these)
local http = require("socket.http")
local ltn12 = require("ltn12")
_H = display.contentHeight
@phpedinei
phpedinei / bodyFlipper.lua
Created May 7, 2016 04:26
Physics Body Flipper Function | Corona SDK
local physics = require( "physics" ) ; physics.start() ; physics.setDrawMode( "hybrid" )
local function flipBody( thisBody )
local flippedBodyShapes = {}
for i=1,#thisBody do
local thisShape = thisBody[i]
local flippedShape = {}
@phpedinei
phpedinei / config.lua
Created May 7, 2016 04:25 — forked from pkoperek/config.lua
ultimate config.lua for corona sdk
-- http://coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/
-- calculate the aspect ratio of the device:
local aspectRatio = display.pixelHeight / display.pixelWidth
application = {
content = {
width = aspectRatio > 1.5 and 320 or math.ceil( 480 / aspectRatio ),
height = aspectRatio < 1.5 and 480 or math.ceil( 320 * aspectRatio ),
scale = "letterBox",
fps = 30,