Skip to content

Instantly share code, notes, and snippets.

View ultimateprogramer's full-sized avatar

Ahmed Maawy ultimateprogramer

View GitHub Profile
#!/usr/bin/env python
# encoding=utf-8
'''
formhub data importer
Automates the submission of formhub XForms from a CSV file,
possibly an export from another formhub form.
Launch with `bulk` argument to trigger bulk submission behavior (only
@ultimateprogramer
ultimateprogramer / .htaccess
Created September 29, 2015 14:38
CI: Simple .htaccess using mod_rewrite for CodeIgniter
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@ultimateprogramer
ultimateprogramer / CustomRequest.java
Created October 20, 2015 08:41
CustomRequest is a way to solve the Volley's JSONObjectReuqest cant post paramsters like the StringRequest
package com.greenchiu.nets;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
@ultimateprogramer
ultimateprogramer / nodejs-tcp-example.js
Created March 6, 2016 19:59 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@ultimateprogramer
ultimateprogramer / ApiController.php
Created April 15, 2016 11:58 — forked from atrakeur/ApiController.php
An laravel's style implementation of API handler.
<?php
/*************************************************
* API base controller for laravel
*************************************************/
class ApiController extends Controller {
/**
* Create a json Response including errors and no data
* @param array $errors the errors
* @return responce The responce including error data
[supervisord]
nodaemon=true
loglevel=debug
[program:amon]
command=gunicorn -c gunicorn.conf.py wsgi
directory=/amon
autostart=true
autorestart=true
redirect_stderr=true
@ultimateprogramer
ultimateprogramer / BlogController.php
Created June 29, 2016 18:54 — forked from tobysteward/BlogController.php
Laravel AJAX Pagination with JQuery
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
@ultimateprogramer
ultimateprogramer / app_route_target.js
Created January 30, 2019 08:45 — forked from hojberg/app_route_target.js
Simple Aviator/React example. Read more about Aviator here: https://github.com/swipely/aviator
/** @jsx React.DOM */
var AppRouteTarget = {
setupLayout: function () {
React.renderComponent({
<App className='page-content'>,
document.querySelector('body')
});
}
};

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 / 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!');