Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
@cstrap
cstrap / ltme
Created February 21, 2017 10:07
Localtunnel
#!/bin/bash
DOMAIN=$1
PORT=$2
if [ $# -eq 0 ] ; then
echo "No arguments supplied"
echo "Usage: clito DOMAIN PORT"
exit 1
fi
@cstrap
cstrap / progressive-ace.htm
Created February 3, 2017 17:05 — forked from duncansmart/progressive-ace.htm
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
@cstrap
cstrap / slack_deploy_bot_template.py
Created August 23, 2016 09:49 — forked from achauve/slack_deploy_bot_template.py
Template of Slack bot for deployment
import logging
import os
import time
import traceback
# pip install slackclient
from slackclient import SlackClient
@cstrap
cstrap / sample_usage.py
Created June 23, 2016 13:00 — forked from luke14free/sample_usage.py
Simple type checked objects in Python
#!/usr/bin/env python
from type_checked_entities import entity_factory
Giraffe = entity_factory( # let's define what is a giraffe!
"giraffe",
name=str, # my name is a string
age=float, # my age is an int
eats=object, # I eat pretty much everything.
)
@cstrap
cstrap / data-uri.py
Created June 6, 2016 16:19 — forked from jsocol/data-uri.py
Give an image, get a data-uri
#!/usr/bin/env python
"""Command line script to convert a file, usually an image, into a data URI
for use on the web."""
import base64
import mimetypes
import os
import sys
@cstrap
cstrap / sudo.py
Created April 21, 2016 09:46 — forked from barneygale/sudo.py
import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""
@cstrap
cstrap / null_write.py
Last active March 9, 2016 09:13
Sample of "null writing" to file.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
class File(io.FileIO):
def __init__(self, name, mode='r', closefd=True, **kwargs):
self.wf = kwargs.pop('wf', True)
super(File, self).__init__(name, mode, closefd)
@cstrap
cstrap / Vagrantfile
Created March 7, 2016 17:43 — forked from gabrielelana/Vagrantfile
How to create a VirtualBox machine with encrypted storage with Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
PASSWORD_PATH = ".password"
PASSWORD_ID_PATH = ".password_id"
# Make sure to have installed vagrant-triggers plugin
# > vagrant plugin install vagrant-triggers
# After the first `vagrant up` stop the VM and execute the following steps
@cstrap
cstrap / Vagrantfile
Last active March 12, 2017 02:26
Python, virtualenvwrapper, pyenv and PostgreSQL - Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false
config.vm.hostname = 'brespio.local'
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder '.', '/vagrant', nfs: true
@cstrap
cstrap / setup_server.md
Last active May 5, 2016 14:19
Setup private PyPI aka Cheeseshop
  • Create virtualenv, command refer to virtualenvwrapper
$ mkvirtualenv cheeseshop 
  • Once created
(cheeseshop) $ pip install -U pip setuptools wheel pypiserver passlib