Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
| ## Alexey Kachayev, 2014 | |
| ## Link to slides: | |
| ## http://goo.gl/n4ylC4 | |
| ## Basic: | |
| ## type Parser = String -> Tree | |
| ## Composition | |
| ## type Parser = String -> (Tree, String) |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| # How to echobot with XMPP, BOSH, and Strophe | |
| 1. Setup ejabberd(http://www.ejabberd.im/) server and setup account [email protected] | |
| NOTE: localhost should be enough. If you setup something else, make sure you add it at /etc/hosts like this | |
| #/etc/hosts | |
| 127.0.0.1 localhost.local | |
| NOTE: Also download Psi(http://psi-im.org/), and make sure you can connect to your ejabberd server. | |
| 2. Download strophe(http://code.stanziq.com/strophe/) and place it (eg: /Users/makoto/work/sample/strophejs-1.0) |
| # Get Root | |
| sudo su | |
| # Download NMON archive | |
| cd /tmp | |
| wget http://nmon.sourceforge.net/docs/MPG_nmon_for_Linux_14a_binaries.zip | |
| # Install unzip if you don't have | |
| yum install unzip |
| from datetime import datetime | |
| from sqlalchemy import Column, Integer, DateTime, ForeignKey | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.ext.declarative import declared_attr | |
| from flask_security import current_user | |
| class AuditMixin(object): | |
| created_at = Column(DateTime, default=datetime.now) | |
| updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now) |
| #!/usr/bin/env python | |
| import sys, os, time, atexit | |
| from signal import SIGTERM | |
| class Daemon: | |
| """ | |
| A generic daemon class. | |
| Usage: subclass the Daemon class and override the run() method |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| /* | |
| * MCrypt API available online: | |
| * http://linux.die.net/man/3/mcrypt | |
| */ | |
| #include <mcrypt.h> |
| from requests_oauthlib import OAuth2Session | |
| from flask import Flask, request, redirect, session, url_for | |
| from flask.json import jsonify | |
| import os | |
| app = Flask(__name__) | |
| # This information is obtained upon registration of a new GitHub | |
| client_id = "<your client key>" |
| from celery.task import task | |
| from my_app.models import FailedTask | |
| from django.db import models | |
| @task(base=LogErrorsTask) | |
| def some task(): | |
| return result | |
| class LogErrorsTask(Task): | |
| def on_failure(self, exc, task_id, args, kwargs, einfo): |