Skip to content

Instantly share code, notes, and snippets.

View ramaseshan's full-sized avatar

Ramaseshan ramaseshan

View GitHub Profile
@simonw
simonw / recover_source_code.md
Last active May 18, 2024 01:57
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@ChillarAnand
ChillarAnand / regex-demo.py
Last active January 21, 2016 14:31
BangPypers talk - Using Regular Expressions by Arvind Padmanabhan
import re
print(re.match(r'bc', 'abc'))
print(re.match(r'abc', 'abc'))
print(re.search(r'bc', 'abc'))
print(re.search(r'^bc', 'abc'))
print(re.search(r'^ab$', 'abc'))
print(re.search(r'^abc$', 'abc'))
print(re.search(r'a?bc', 'bc'))
print(re.search(r'a?bc', 'abc'))
print(re.search(r'a?bc', 'aabc'))
[2015-06-30 12:26:32.334650] I [MSGID: 100030] [glusterfsd.c:2301:main] 0-/usr/sbin/glusterd: Started running /usr/sbin/glusterd version 3.7.2 (args: /usr/sbin/glusterd -p /var/run/glusterd.pid)
[2015-06-30 12:26:32.338855] I [glusterd.c:1372:init] 0-management: Maximum allowed open file descriptors set to 65536
[2015-06-30 12:26:32.338886] I [glusterd.c:1420:init] 0-management: Using /var/lib/glusterd as working directory
[2015-06-30 12:26:32.345185] W [rdma.c:4493:__gf_rdma_ctx_create] 0-rpc-transport/rdma: rdma_cm event channel creation failed (No such device)
[2015-06-30 12:26:32.345209] W [rdma.c:4793:init] 0-rdma.management: Failed to initialize IB Device
[2015-06-30 12:26:32.345218] W [rpc-transport.c:358:rpc_transport_load] 0-rpc-transport: 'rdma' initialization failed
[2015-06-30 12:26:32.345297] W [rpcsvc.c:1595:rpcsvc_transport_create] 0-rpc-service: cannot create listener, initing the transport failed
[2015-06-30 12:26:32.345324] E [MSGID: 106243] [glusterd.c:1646:init] 0-management: creation of 1
@rajanm
rajanm / !Elasticsearch Samples.md
Last active September 20, 2020 23:55
Elasticsearch Sample Scripts

This gist contains various example scripts for Elasticsearch. These scripts have been tested with Elasticsearch Server v1.5.2. These scripts can be run from shell/terminal in a Unix or from git bash in a Windows.

For a full fledged Java sample project, refer - ElasticsearchJavaSample

anonymous
anonymous / config.json
Created December 10, 2014 09:49
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "#FFA233",
"@brand-success": "#21a685",
@jaivikram
jaivikram / getVideoDetails.py
Last active April 18, 2020 13:02
Python gist to obtain video details like duration, resolution, bitrate, video codec and audio codec, frequency using 'ffmpeg'
#! /usr/bin/env python
import os
import sys
import re
import tempfile
def getVideoDetails(filepath):
tmpf = tempfile.NamedTemporaryFile()
os.system("ffmpeg -i \"%s\" 2> %s" % (filepath, tmpf.name))
lines = tmpf.readlines()
@valberg
valberg / imagewiththumbnails_updateable.py
Created April 20, 2012 14:55
Django create thumbnail form ImageField and save in a different ImageField - now with updating!
# Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/
# Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join())
class Image(Media):
image = models.ImageField(
upload_to=image_folder
)
thumbnail = models.ImageField(