Skip to content

Instantly share code, notes, and snippets.

@foghina
foghina / gist:1206035
Created September 9, 2011 11:58
Sublime Text 2 Failed Snippet
[
{ "keys": ["ctrl+shift+i"], "command": "insert_snippet", "args": {"contents": "I18n.t($SELECTION)"}, "context":
[
{"key": "scope", "operator": "regex_contains", "operand": "ruby", "match_all": true }
]
}
]
@foghina
foghina / sublime-text.desktop
Created September 18, 2012 08:27
Sublime Text 2 .desktop file
# ~/.local/share/applications/sublime-text.desktop
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/opt/sublime/sublime_text %U
MimeType=text/plain;
Name=Sublime Text 2
Comment=Sublime Text is a sophisticated text editor for code, html and prose. You'll love the slick user interface and extraordinary features.
@foghina
foghina / bashsurv.sh
Last active October 12, 2015 22:58
Video Surveillance in Bash
#!/bin/bash
OUTPUT_DIR="/var/www/bashsurv"
FFMPEG_INPUT_FLAGS="-rtsp_transport tcp"
FFMPEG_SOURCE="rtsp://192.168.1.123/video.mp4"
FFMPEG_OUTPUT_FLAGS="-r 20 -acodec libspeex"
FFMPEG_OUTPUT_EXT="ogv"
CLIP_LENGTH=600 # seconds
TIMELIMIT=620 # seconds, allows for network timeout over CLIP_LENGTH
KEEP_FILES_FOR=10080 # minutes
PS1='\[\033[1;32m\]\w`__git_ps1`€\[\033[0m\] '
#!/usr/bin/python
# Set up a new A record in Cloudflare, add the details of it along with your account details below
# Make sure this script runs on startup (or whenever you get a new IP...)
#
# Updated for Python 3.
#
# @author Aaron Rice <aaron@duedil.com>
# @author Felix Oghină <felix@oghina.com>
  • [46dc46a] changes when we clear the current activity from the ReactContext: moved it from onPause to onDestroy. This is generally good news, as you have access to the Activity in more situations, but if you were relying on the Activity being null in paused state, you'll need to change your code.
  • [0b5c612] changes how we forward Activity lifecycle events to listeners: we no longer send events generated by background Activities. The biggest implication of this is probably that, if you are using multiple React Activities, won't receive onHostDestroy() until the last React Activity is destroyed. Furthermore, if you're writing your own custom activities, make sure to call the new API (ReactInstanceManager#onHostPause(Activity) and co.) to benefit from this.
  • [3c4fd42] adds a FragmentActivity-based React Activity class, to support using libraries that rely on this. In order to achieve DRY, most of the Activity methods (onCreate, getReactNativeHost etc.) are now delegated to `ReactAc
import socket
import struct
import time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.1.119', 27007))
s.send(b'\x43\x52\x57\x48\x01'.ljust(128, b'\0'))
data = s.recv(132)
(len_response,) = struct.unpack('12xi', data[:16])
data = s.recv(len_response)