Skip to content

Instantly share code, notes, and snippets.

@ultimateprogramer
ultimateprogramer / compile.sh
Last active August 21, 2020 14:41
Example on how to implement Lua functions that run C Code
#!/bin/sh
gcc -Wall -shared -fPIC -o power.so -I/usr/include/lua5.1 -llua5.1 hellofunc.c
# Notes:
# gcc
# The compiler
# -Wall
# Warn on almost anything
@ultimateprogramer
ultimateprogramer / README.md
Created August 15, 2020 17:16 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

// uses Apache commons CSV, IO and Lang
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
@ultimateprogramer
ultimateprogramer / raycast.hx
Created July 14, 2020 18:08 — forked from jah2488/raycast.hx
A simple raycasting proof of concept I did a few months back in haxe/openfl. Think of the original doom. Its kinda like that.
package;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.Lib;
import flash.ui.Keyboard;
import flash.Vector;
@ultimateprogramer
ultimateprogramer / firebase_detect_data.js
Created June 19, 2020 21:40 — forked from anantn/firebase_detect_data.js
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');

Keybase proof

I hereby claim:

  • I am ultimateprogramer on github.
  • I am ahmedmaawy (https://keybase.io/ahmedmaawy) on keybase.
  • I have a public key ASA5pSwuPepzpdRHH0ZBNEu_i0sVMTkxOh2Ny2N5C9vF9Ao

To claim this, I am signing this object:

@ultimateprogramer
ultimateprogramer / Snippets.md
Last active January 14, 2020 19:16
Useful ct.js Code Snippets

Move an object a specific direction

  • Speed of 3
  • Direction - Downwards
  • Set a timer for bullets
  • Sets explicitly the object type as string
/**
 * OnCreate - Move an object a specific direction and set a "Type"

Attach the script to a go containing the camera and send a message to that script with four parameters:

  • x = amount of shake in x-direction
  • y = amount of shake in y-direction
  • time = duration of shake in seconds
  • speed = shakes per second - lower number means faster shaking

To try it out you can simply hot reload the script and it will initiate a shake immediately.

@ultimateprogramer
ultimateprogramer / Dockerfile
Created August 20, 2019 13:00
Ruby on Rails Docker Container from Scratch - Ubuntu
# Derive an Ubuntu Image
FROM ubuntu:18.04
# Update and Upgrade
RUN apt-get update
RUN apt-get upgrade
# Install base `ruby`
RUN sudo apt install ruby
# Rails installs as a GEM
@ultimateprogramer
ultimateprogramer / Cheffile
Created August 19, 2019 19:25
Using Vagrant for Rails Development
site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'build-essential'
cookbook 'system'
cookbook 'ruby_build'
cookbook 'ruby_rbenv', '~> 1.1.0'
cookbook 'postgresql', git: 'https://github.com/ChowOps/chef-postgresql'
cookbook 'vim'