Skip to content

Instantly share code, notes, and snippets.

View ysf's full-sized avatar
💭
writing jokes.

ysf ysf

💭
writing jokes.
View GitHub Profile
.text
.global _start
_start:
# setresuid() syscall
# Narnia FIX: Bash drop the setuid bit if EUID != RUID
# I need to call setresuid() to set a different RUID
xor %eax, %eax # Cleaning syscall number
@ysf
ysf / dns_server.py
Created September 11, 2017 10:58
requires python 3.5+ and dnslib, see https://github.com/samuelcolvin/dnserver for full/better implementation
from datetime import datetime
from time import sleep
from dnslib import DNSLabel, QTYPE, RD, RR
from dnslib import A, AAAA, CNAME, MX, NS, SOA, TXT
from dnslib.server import DNSServer
EPOCH = datetime(1970, 1, 1)
SERIAL = int((datetime.utcnow() - EPOCH).total_seconds())
# source from .bashrc for lazy pipe grep magic
command_not_found_handle ()
{
# only run within an input pipe
if [[ -p /dev/stdin ]]; then
grep -- "$*"
return $?
fi

Keybase proof

I hereby claim:

  • I am ysf on github.
  • I am ysf (https://keybase.io/ysf) on keybase.
  • I have a public key whose fingerprint is C164 E108 8854 3B27 F961 6703 9DDA 5F79 EFE3 EBDF

To claim this, I am signing this object:

#!/usr/bin/env python
# hack to provide a repeat statement in reply to: https://gist.github.com/ychaouche/f30d5e07012454fff0d2
import inspect
def repeat(count):
if not hasattr(repeat, "loops"):
repeat.loops = {}
@ysf
ysf / collector_transaction.rb
Created August 16, 2012 09:13 — forked from gravis/collector_transaction.rb
A secure event tracking system for online betting in France
# Copyright © 2010-2011 Tech-Angels. All Rights Reserved.
# CollectorTransaction will be created each time the Collector needs
# to trace an activity.
#
# Attributes:
# * id [integer, primary, not null] - primary key
# * before_tr [binary] - associated model serialized before transaction
# * created_at [datetime] - creation time
# * model_id [integer] - belongs_to Model (polymorphic)
@ysf
ysf / deploy.rb
Created September 25, 2009 11:31
usage: 'cap deploy:setup' for initialization. 'cap deploy' for updates and cap 'deploy:restart' for passenger restart. only the latest four releases are left on the server.
set :application, "application_name"
set :rails_env, 'production' # only needed for migrations
set :user, "webXX"
role :web, "serverX.domaincamp.de" # Your HTTP server, Apache/etc
role :app, "serverX.domaincamp.de" # This may be the same as your `Web` server
role :db, "serverX.domaincamp.de", :primary => true # This is where Rails migrations will run
set :scm, :git
set :repository, "git@yourgithost.tld:username/project/project.git"
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"