Skip to content

Instantly share code, notes, and snippets.

@ultimateprogramer
ultimateprogramer / client_secrets.php
Created July 5, 2017 17:47
Using Client Secrets with Google API PHP
<?php
require_once __DIR__.'/vendor/autoload.php';
// For PHP you will need to define GOOGLE_APPLICATION_CREDENTIALS environment variable and point it to the path of the file
// You do not need to do this for Google App Engine
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
@ultimateprogramer
ultimateprogramer / BrickCollision.cs
Created July 7, 2017 09:51
Unity3D Code Snippets of Interest from AngryBirdsClone
public float Health = 70f;
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.GetComponent<Rigidbody2D>() == null) return;
float damage = col.gameObject.GetComponent<Rigidbody2D>().velocity.magnitude * 10;
//don't play audio for small damages
if (damage >= 10)
GetComponent<AudioSource>().Play();
@ultimateprogramer
ultimateprogramer / Dockerfile
Created July 26, 2017 12:40
Install Mongo Drivers from PHP Docker
FROM php:7.0.4-fpm
# Install modules
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libssl-dev \
&& pecl install mongodb \
@ultimateprogramer
ultimateprogramer / MongoDBSSIS.cs
Created July 27, 2017 13:15
MongoDB SSIS Integration
// Download the MongoDB C# Drivers from https://docs.mongodb.com/ecosystem/drivers/csharp/
// Add the references to your project.
// Create a Script Task. Now in the script, expand the Namespaces region and add these lines:
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Bson.Serialization;
// Now scroll down to the CreateNewOutputRows() procedure. Here is a sample of the code I used:
gcc main.c -shared -o mylib.so -fPIC -llua
@ultimateprogramer
ultimateprogramer / invalidate.sh
Created October 17, 2018 06:52
Invalidate Heroku NodeJS `node-modules` cache
heroku config:set NODEMODULESCACHE=false
git commit -am 'rebuild' --allow-empty
git push heroku master
heroku config:unset NODEMODULESCACHE
@ultimateprogramer
ultimateprogramer / compiling.md
Created October 17, 2018 09:59
Compiling COCOS Studio for Linux from a Mac image

Since Cocos Creator is an electron app, I thought it should be easy to run it on Linux. As a result, successfully launched Cocos Creator app on Ubuntu.

Cocos Creator

To make it possible,

  • Clone electron tag 1.7.5 which is the version cocos creator uses. Modify atom/common/asar/archive.cc, atom/browser/net/url_request_asar_job.cc and lib/common/asar.js files to decrypt js files and asar header. You can find correct asar.js file from Cocos Creator itself by opening developer tools and find the file ELECTRON_ASAR.js. Finally build the electron by using ./script/create-dist.py

Folder view

@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')
});
}
};
@ultimateprogramer
ultimateprogramer / install.sh
Created March 7, 2019 19:23
Install KTechLab on Ubuntu
sudo apt-get install git kdelibs5-dev kdevplatform-dev qt4-dev-tools cmake libglib2.0-dev
mkdir git-ktechlab && cd git-ktechlab
git clone git://github.com/ktechlab/ktechlab.git
cd ktechlab
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=/usr/local/
make
sudo make install
kbuildsycoca4 &> /dev/null
sudo update-mime-database /usr/share/mime
@ultimateprogramer
ultimateprogramer / receiver-device.ino
Created April 7, 2019 19:59
Communicate between 2 NodeMCUs using MQTT
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "xxx";
const char* password = "xxx";
const char* mqttServer = "m24.cloudmqtt.com";
const int mqttPort = 15031;
const char* mqttUser = "xxx";
const char* mqttPassword = "xxx";