Skip to content

Instantly share code, notes, and snippets.

@b0c1
b0c1 / OrientDbTest.scala
Last active December 17, 2015 06:19
Orient DB 1.3 vs scala 2.10
package hu.javaportal.test
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{BeforeAndAfter, FunSuite}
import org.scalatest.mock.MockitoSugar
import com.orientechnologies.orient.`object`.db.{OObjectDatabasePool, OObjectDatabaseTx}
import com.orientechnologies.orient.core.tx.OTransaction.TXTYPE
import javax.persistence.{Version, Id}
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
@thearn
thearn / capture.py
Created June 15, 2013 21:31
Screen capture using python PIL
import time
import Image
import ImageGrab
while True:
time.sleep(0.5)
t = str(time.time()).replace('.','-')
tt = time.time()
img=ImageGrab.grab()
img = img.resize((800,600))
@khayrov
khayrov / serialize.py
Last active January 26, 2022 02:17
Serializable transactions and retry in SQLAlchemy
from sqlalchemy import (create_engine, event,
Column, Integer,
ForeignKey)
from sqlalchemy import event
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.exc import DBAPIError
import sqlite3
@javiercantero
javiercantero / xreadkeys.c
Last active December 4, 2023 19:04
A X11/Xlib program that reads the KeyPress and KeyRelease events from the window and prints them to the standard output. Used to debug the keyboard within X.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
Display *display;
Window window;
XEvent event;
int s;
@marcoslin
marcoslin / .gitignore
Last active August 31, 2023 15:37
Encryption: From PyCrypto to CryptoJS
source.sh
@Antarix
Antarix / LocalBroadcastExampleActivity.java
Created December 26, 2013 08:31
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@tatac1
tatac1 / gist:8670611
Last active December 5, 2022 07:55
a http-conduit sample
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit
import Network.HTTP.Types.Status
import Network
import Data.Time.Clock
import Data.Time.Calendar
import qualified Control.Exception as E
import qualified Data.ByteString.Lazy as L
past :: UTCTime
past = UTCTime (ModifiedJulianDay 56200) (secondsToDiffTime 0)
@nicktoumpelis
nicktoumpelis / repo-rinse.sh
Created April 23, 2014 13:00
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@tatac1
tatac1 / gist:000ec3ba7530754ad556
Last active December 5, 2022 07:57
error message when use proxy.. "*** Exception: Network/HTTP/Client/Manager.hs:(334,9)-(336,45): Non-exhaustive patterns in case"
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
import Network.Connection (TLSSettings (..))
import Network.HTTP.Conduit
import Network.HTTP.Types.Status
import qualified Data.ByteString.Char8 as B
import qualified Data.Text as T
import Data.Time.Clock
import Data.Time.Calendar
@letmaik
letmaik / models_committed.py
Created May 22, 2014 14:54
delete, insert, update events after a commit for SQLAlchemy
from sqlalchemy import create_engine, event, orm
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.session import Session as SessionBase, object_session
from sqlalchemy.event.api import listen
# The following adds delete, insert, and update events after successful commits.
# SQLAlchemy provides only events after flushes, but not after commits.
# The classes are adapted from Flask-SQLAlchemy.
# see also https://stackoverflow.com/a/12026787/60982