Skip to content

Instantly share code, notes, and snippets.

@vilmosioo
vilmosioo / gist:8146568
Last active January 1, 2016 12:48
How to install Sky Watch client app.
git clone https://github.com/vilmosioo/Sky-Watch.git
cd src/client
bower install & npm install
@vilmosioo
vilmosioo / Gruntfile.js
Last active December 23, 2015 04:39
Example usage of ng-constant to create environment variables.
grunt.initConfig({
ngconstant: {
dev: [
{
dest: 'path/to/constants.js',
name: 'Constants',
constants: {
'<constant name>': grunt.file.readJSON('path/to/dev.json'),
}
}
@vilmosioo
vilmosioo / Gruntfile.js
Created September 16, 2013 15:02
Example usage of ng-constant. Replace <...> with appropriate values.
grunt.initConfig({
ngconstant: {
<task>: [
{
dest: '<destination file>',
name: '<module name>',
constants: {
'<constant name>': '<constant value>',
'<constant name>': { ... }
'<constant name>': grunt.file.readJSON('<JSON file>')
@vilmosioo
vilmosioo / pre-commit
Created September 6, 2013 13:41
Run grunt jshint before every commit. The commit fails if any warnings/errors are generated. Helps avoid "jshint fix" style commits
#!/usr/bin/env node
var exec = require('child_process').exec;
// Runs the build task, in our case `grunt jshint`
exec('grunt jshint', function (error, stdout, stderr) {
// Build task output might be useful to the developer so let's print it
// We could also log it in a file
console.log(stdout);
@vilmosioo
vilmosioo / Picking.java
Created May 23, 2013 11:25
OpenGL picking in Java using the stencil buffer. This script is not meant to work directly, but rather for a simple guide on how to implement picking. it is worth mentioning that this method is just one of many. I also tried using select rendering and color picking methods, but I find this the easiest one to use.
// make sure you enable the stencil buffer when creating the canvas
GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities capabilities = new GLCapabilities(profile);
capabilities.setStencilBits(8);
// when picking, enable stencil test
if (picking) {
gl.glEnable(GL2.GL_STENCIL_TEST);
gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_REPLACE);
} else {
@vilmosioo
vilmosioo / requestAnimationFrame.js
Created May 2, 2013 15:59
JavaScript polyfill for requestAnimationFrame
(function() {
var lastTime = 0;
var vendors = ['webkit', 'moz'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
@vilmosioo
vilmosioo / Convert.php
Created April 21, 2013 02:41
Recently I had to transfer an sqlite database to mysql. Unfortunately, there are a few minor differences between the dump files. This PHP script will try and transform the sqlite dump file to a mysql dump file. Feel free to contribute.
<?php
$read = @fopen("dump_sqlite", "r");
$write = @fopen("dump_mysql", "w");
if ($read && $write) {
while (($buffer = fgets($read, 4096)) !== false) {
// replace all double-quotes (") with grave accents (')
$buffer = preg_replace('/"/', "'", $buffer);
// replace "autoincrement" with "auto_increment"
$buffer = str_replace("autoincrement", "auto_increment", $buffer);
@vilmosioo
vilmosioo / Constellations.php
Last active December 16, 2015 05:09
PHP array of constellation names and their abbreviation.
<?php
$constellations = array(
"Andromeda" => "and",
"Antlia" => "ant",
"Apus" => "aps",
"Aquarius" => "aqr",
"Aquila" => "aql",
"Ara" => "ara",
"Aries" => "ari",
"Auriga" => "aur",
@vilmosioo
vilmosioo / ArcBall.java
Last active November 27, 2017 11:13
Performing the ArcBall rotation effect. This example code is written in Java and used with OpenGL but it can be adapted to other technologies. Many thanks to the great developers that helped me use this. The idea of the ArcBall rotation and how to implement it are NOT mine but it took some time to integrated with my application. I hope this gist…
public class ArcBall {
private static final float Epsilon = 1.0e-5f;
Vector3f StVec; // Saved click vector
Vector3f EnVec; // Saved drag vector
float adjustWidth; // Mouse bounds width
float adjustHeight; // Mouse bounds height
public ArcBall(float NewWidth, float NewHeight) {
@vilmosioo
vilmosioo / Github_API.php
Created February 14, 2013 16:04
Github API helper class. Uses the github api to retrieve public gists, repos or commits for a specific user
<?php
/*
* Github API helper class
*
* Uses the github api to retrieve public gists, repos or commits for a specific user
*/
class Github_API{
static function get_data($url){
$base = "https://api.github.com/";
$response = wp_remote_get($base . $url, array( 'sslverify' => false ));