Skip to content

Instantly share code, notes, and snippets.

@kopiro
kopiro / final.base.opengl.gl.cpp
Last active December 11, 2015 04:38
Final revision of advanced base in OpenGL++
// g++ src.cpp -­lglut ­-lGL ­-lGLU; ./a.out
#include <iostream>
#include <cmath>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
// CAMERA position
GLfloat CAMERA_X = 0;
GLfloat CAMERA_Y = 0;
@kopiro
kopiro / fixed-sidebar-scroll.js
Created March 8, 2013 14:16
Scrollbar fixed in JS
self.sidebarAutoScroll = function()
{
window.content = $('#page>.row>div:eq(0)');
window.sidebar = $('#page>.row>div:eq(1)');
sidebar.data('initial-offset', sidebar.offset());
sidebar.data('initial-height', sidebar.height());
if (sidebar.data('initial-height')<content.height() && sidebar.data('initial-height')<$(window).height() && $(window).width()>768) {
console.log('Using sidebarAutoScroll');
var footerOffset = $('#footer').offset().top;
$(window).scroll(function(e){
char** explode(char delimiter, char* str) {
int l = strlen(str), i=0, j=0, k=0;
char x = NULL;
char** r = (char**)realloc(r, sizeof(char**));
r[0] = (char*)malloc(l*sizeof(char));
while (i<l+1) {
x = str[i++];
if (x==delimiter || x=='\0') {
r[j][k] = '\0';
r[j] = (char*)realloc(r[j], k*sizeof(char));
#!/usr/bin/osascript
tell application "Google Chrome"
execute front window's active tab javascript "window.open('https://www.facebook.com/sharer/sharer.php?u='+location.href, 'Facebook', 'width=600,height=400')"
end tell
@kopiro
kopiro / postepay.php
Last active April 5, 2020 11:21
Check Postepay money via PHP & CURL
#!/usr/bin/php
<?php
/*
To install, just run this command:
sudo curl https://gist.github.com/kopiro/5720439/raw -o /usr/local/bin/postepay && sudo chmod +x /usr/local/bin/postepay
And, edit with:
sudo nano /usr/local/bin/postepay
@kopiro
kopiro / get-tweets-11.php
Last active May 22, 2016 17:01
Get Tweets in PHP with OAUTH2
<?php
function buildBaseString($baseURI, $method, $params) {
$r = array();
ksort($params);
foreach($params as $key=>$value){
$r[] = "$key=" . rawurlencode($value);
}
return $method."&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r));
}
@kopiro
kopiro / experimental-sliding-menu.js
Created June 26, 2013 09:35
Experimental sliding menu in Titanium
this.currentWindow.addEventListener('touchstart', function(e) {
if (Alloy.Globals.UI.data.unmovableElements.indexOf(e.source.toString())>=0) return;
if (true===Alloy.Globals.UI.leftMenuOpen || true===Alloy.Globals.UI.rightMenuOpen) return;
Alloy.Globals.UI.data.menuX = e.x;
Alloy.Globals.UI.data.deltaX = 0;
});
this.currentWindow.addEventListener('touchmove', function(e) {
if (Alloy.Globals.UI.data.unmovableElements.indexOf(e.source.toString())>=0) return;
@kopiro
kopiro / alarm.scpt
Last active July 25, 2017 09:58
Alarm applescript for Spotify
set volume 5
set today to (date string of (current date))
set weather to do shell script "~/bin/weather"
set weatherc to do shell script "~/bin/weatherc"
set inboxcount to do shell script "~/bin/inbox-count"
set spotidelay to 1
tell application "Spotify"
@kopiro
kopiro / $_GET.js
Created September 26, 2013 18:45
Simply, $_GET!
function $_GET(v) {
var m = location.href.match(v+"=([^&]*)");
return m && m.length>=1 ? m[1] : null;
}
@kopiro
kopiro / fb-scroll-messages.js
Last active February 26, 2021 11:04
Facebook: scroll in the messages to a particular date
javascript:
(function(){
function _(a) { return document.querySelectorAll(a); }
var to = new Date(prompt('Arrival date', '2013/04/18')).getTime()/1000;
if (!to) return alert('Invalid date');
var thetime = 0;
var sametimes = 0;
function thefoo(){
var time = parseInt(_('.webMessengerMessageGroup')[0].querySelector('[data-utime]').dataset.utime,10);
if (time==thetime) {