Skip to content

Instantly share code, notes, and snippets.

View martinsik's full-sized avatar

Martin Sikora martinsik

View GitHub Profile
@martinsik
martinsik / chat-frontend.js
Last active September 24, 2024 14:54
Node.js chat frontend and server
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
<!--
Tutorial code for: http://www.binpress.com/tutorial/generating-nice-movie-previews-with-ffmpeg/138
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<a href="https://www.youtube.com/watch?v=v1uyQZNg2vE" target="_blank" class="video-preview" data-frames="100" data-source="http://i.imgur.com/BX0pV4J.jpg"></a>
@martinsik
martinsik / circle_detection.py
Last active April 22, 2023 09:50
Circle detection with OpenCV 3.0
import cv2
import time
import math
import numpy as np
capture = cv2.VideoCapture(0)
print capture.get(cv2.CAP_PROP_FPS)
t = 100
w = 640.0
@martinsik
martinsik / MyCalendar.h
Created March 8, 2013 09:47
Example of using EventKit on iOS 6+
#import <Foundation/Foundation.h>
@interface MyCalendar : NSObject
+ (void)requestAccess:(void (^)(BOOL granted, NSError *error))success;
+ (BOOL)addEventAt:(NSDate*)eventDate withTitle:(NSString*)title inLocation:(NSString*)location;
@end
@martinsik
martinsik / libwebsockets-webserver.c
Created July 31, 2012 11:34
Simple webserver based on libwebsockets library. Read full description at http://martinsikora.com/libwebsockets-simple-http-server
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libwebsockets.h>
static int callback_http(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
@martinsik
martinsik / index.html
Created September 6, 2012 10:03
Simple WebSocket server based on libwebsockets. For full description read http://martinsikora.com/libwebsockets-simple-websocket-server
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
window.WebSocket = window.WebSocket || window.MozWebSocket;
var websocket = new WebSocket('ws://127.0.0.1:9000',
@martinsik
martinsik / parser.php
Created October 2, 2012 19:45
Simple sport results parser in PHP using XPath. For more information visit http://martinsikora.com/parsing-html-pages-using-xpath
<?php
$curl = curl_init('http://www.livescore.com/soccer/england/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
$html = curl_exec($curl);
curl_close($curl);
if (!$html) {
@martinsik
martinsik / webgl-demo.dart
Last active November 7, 2020 18:24
Dart + WebGL. For more information visit http://martinsikora.com/dart-webgl-simple-demo
import 'dart:html';
/**
* WebGL Demo made in Dart.
* Updated: March 11th 2013 - Dart SDK 0.4.1
* This example is heavily inspired by:
* http://www.netmagazine.com/tutorials/get-started-webgl-draw-square
*/
class WebGLTest {
@martinsik
martinsik / ViewController.mm
Last active July 9, 2018 09:17
Source codes for tutorial on Creating .mbtiles DB for iOS MapBox from hi-res map image http://martinsikora.com/creating-mbtiles-db-for-ios-mapbox-from-hi-res-map-image
#import "ViewController.h"
#import "MapBox.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
RMMBTilesSource *offlineSource = [[RMMBTilesSource alloc] initWithTileSetURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"chernarus" ofType:@"mbtiles"]]];
@martinsik
martinsik / apd-php54.diff
Created August 11, 2012 07:39
Patch file for APD 1.0.1 that fixes bugs for PHP 5.4
--- php_apd.c.orig 2004-09-28 05:25:59.000000000 +0200
+++ php_apd.c 2012-08-11 10:59:29.000000000 +0200
@@ -70,7 +70,7 @@
/* List of exported functions. */
-function_entry apd_functions[] = {
+zend_function_entry apd_functions[] = {
PHP_FE(override_function, NULL)
PHP_FE(rename_function, NULL)