Skip to content

Instantly share code, notes, and snippets.

View AlexanderSavochkin's full-sized avatar

Alexander Savochkin AlexanderSavochkin

  • Greater Seattle Area
View GitHub Profile
@anandnalya
anandnalya / app_1.js
Created March 19, 2012 07:32
Building a Single Page Webapp with jQuery
$(document).ready(function() {
// convert all a/href to a#href
$("body").delegate("a", "click", function(){
var href = $(this).attr("href"); // modify the selector here to change the scope of intercpetion
// Push this URL "state" onto the history hash.
$.bbq.pushState(href,2);
// Prevent the default click behavior.
@zester
zester / SFML2 and OpenSceneGraph 3
Created April 17, 2012 01:08
SFML2 and OpenSceneGraph 3
// g++ main.cpp -o main -lsfml-window -lsfml-graphics -lsfml-system -losg -losgDB -losgGA -losgUtil
#include <SFML/Graphics.hpp>
#include <osgUtil/SceneView>
#include <osg/Node>
#include <osg/CameraNode>
#include <osg/Group>
#include <osgDB/ReadFile>
#include <errno.h>
#include <fcntl.h>
#include <linux/videodev2.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <opencv2/core/core.hpp>
@pklaus
pklaus / arduino-due_high-speed-ADC.ino
Last active October 4, 2023 02:20
Arduino Due: ADC → DMA → USB @ 1MSPS
#undef HID_ENABLED
// Arduino Due ADC->DMA->USB 1MSPS
// by stimmer
// from http://forum.arduino.cc/index.php?topic=137635.msg1136315#msg1136315
// Input: Analog in A0
// Output: Raw stream of uint16_t in range 0-4095 on Native USB Serial/ACM
// on linux, to stop the OS cooking your data:
// stty -F /dev/ttyACM0 raw -iexten -echo -echoe -echok -echoctl -echoke -onlcr
@thvasilo
thvasilo / lzo.sh
Last active October 10, 2015 04:25
Script to install components needed to read LZO-compressed files in Apache Spark
#!/bin/bash
# Step 1: Install LZO dependencies
yum -y install lzo lzo-devel lzop
# Step 2: Install maven
MVN_VERSION=3.2.5
MVN_MD5=b2d88f02bd3a08a9df1f0b0126ebd8dc
# wget http://www.apache.org/dyn/closer.cgi/maven/maven-3/$MVN_VERSION/binaries/apache-maven-$MVN_VERSION-bin.tar.gz
wget http://apache.claz.org/maven/maven-3/$MVN_VERSION/binaries/apache-maven-$MVN_VERSION-bin.tar.gz
@thvasilo
thvasilo / TestNgrams.scala
Created March 23, 2015 11:09
Simple job to ensure LZO compressed Google Ngrams data can be read
import org.apache.spark._
import org.apache.spark.SparkContext._
import org.apache.spark.rdd.RDD
import scala.util.Random
import java.io._
import java.util.Properties
import org.apache.hadoop.fs._;
import org.apache.hadoop.conf._;
import org.apache.hadoop.io._;
@fmder
fmder / elastic_transform.py
Last active August 22, 2021 14:54
Elastic transformation of an image in Python
import numpy
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@ViteFalcon
ViteFalcon / BackgroundImage.cpp
Last active September 9, 2019 07:13
OpenSceneGraph: Creating background image
// create a camera to set up the projection and model view matrices, and the subgraph to draw in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera();
// set the view matrix
camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
// use identity view matrix so that children do not get (view) transformed
camera->setViewMatrix(osg::Matrix::identity());
// set the projection matrix to be of width and height of 1
camera->setProjectionMatrix(osg::Matrix::ortho2D(0, 1.0f, 0, 1.0f));
// set resize policy to fixed
@chsasank
chsasank / elastic.lua
Last active September 6, 2021 08:31
Elastic transformation/deformation of an image in Torch
require 'image'
function ElasticTransform(img, alpha, sigma)
--[[
Parameters
----------
img: Tensor of size KxHxW
Image on which elastic transformation have to be applied
alpha: number
Intensity of the transformation
@mbollmann
mbollmann / attention_lstm.py
Last active June 26, 2023 10:08
My attempt at creating an LSTM with attention in Keras
class AttentionLSTM(LSTM):
"""LSTM with attention mechanism
This is an LSTM incorporating an attention mechanism into its hidden states.
Currently, the context vector calculated from the attended vector is fed
into the model's internal states, closely following the model by Xu et al.
(2016, Sec. 3.1.2), using a soft attention model following
Bahdanau et al. (2014).
The layer expects two inputs instead of the usual one: