Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
chrisguitarguy / server.py
Created October 24, 2011 03:14
Super simple python socket server and HTTP request class.
import socket, traceback
HOST = ''
PORT = 51235
CLRF = '\r\n'
class InvalidRequest(Exception):
pass
class Request(object):
@papaeye
papaeye / test_context.py
Created May 27, 2013 09:22
Test push/pop of Flask application/request context
import unittest
from flask import Flask
from flask.globals import _app_ctx_stack, _request_ctx_stack
class TestContext(unittest.TestCase):
def setUp(self):
self.app = Flask(__name__)
@spekkionu
spekkionu / composer.json
Created October 9, 2014 20:07
Standalone validation using laravel validation component
{
"name": "spakkionu/validate",
"description": "Validation Test",
"require": {
"illuminate/validation": "~4.2.9"
},
"license": "MIT",
"authors": [
{
"name": "Jonathan Bernardi",
@NamPNQ
NamPNQ / .gitconfig
Created February 17, 2016 06:33 — forked from ViktorStiskala/.gitconfig
Pycharm as a default git difftool and git mergetool. Add the following to ~/.gitconfig
[diff]
tool = pycharm
[difftool "pycharm"]
cmd = /usr/local/bin/charm diff "$LOCAL" "$REMOTE" && echo "Press enter to continue..." && read
[merge]
tool = pycharm
keepBackup = false
[mergetool "pycharm"]
cmd = /usr/local/bin/charm merge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
@ankurk91
ankurk91 / xdebug-mac.md
Last active March 9, 2024 22:20
php xDebug v3 on Ubuntu/Mac and phpStorm

🪲 Install and Configure xDebug v3 on MacOS for PhpStorm 🐘

  • Assuming that you have already installed php and apache via Homebrew

  • Install xDebug php extension

pecl channel-update pecl.php.net
pecl clear-cache

pecl install xdebug
@absent1706
absent1706 / activate.bat
Last active March 2, 2017 11:25
knowstory-env
@echo off
set "ROOT_DIR=E:\code\knowstory"
set "VIRTUAL_ENV=%ROOT_DIR%\env"
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (#!E:\Python\python.exe
import re
import sys
@absent1706
absent1706 / sqlalchemy_debug_utils.py
Last active March 27, 2017 14:32
SQLAlchemy debug utils
def to_sql(query, dialect_name=None):
from sqlalchemy import dialects
import operator
if dialect_name:
dialect_module = getattr(dialects, dialect_name)
if not dialect_module:
raise KeyError('Wrong dialect {}'.format(dialect_name))
dialect = dialect_module.dialect()
else:
STACKDRIVER_ERROR_FILE = '/var/log/app_engine/custom_logs/errors.log.json'
def log_stackdriver_err(request=None, exception=None, user=None):
'''
send error to StackDriver Error Reporting service
see https://cloud.google.com/error-reporting/docs/setup/app-engine-flexible-environment
'''
def make_path_to_file(filename):
if not os.path.exists(os.path.dirname(filename)):
<?php
$the_folder = '.';
$zip_file_name = '1.zip';
$download_file= true;
//$delete_file_after_download= true; doesnt work!!
class FlxZipArchive extends ZipArchive {
/*
* If you have
* .oneline {
* overflow: hidden;
* white-space: nowrap;
* text-overflow: ellipsis
* }
*
* inside Bootstrap's .media-body, i.g.:
*