Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
PuercoPop / gist:5357159
Last active December 16, 2015 01:39
Test case for py.test and freeze gun
# -*- coding: utf-8 -*-
import sys
import pytest
import datetime
from freezegun.api import FakeDate, FakeDatetime
real_date = datetime.date
real_datetime = datetime.datetime
;; Thanks to tali713
(defun backward-kill-word-or-kill-region ()
"When no region is active call backward-kill-word, otherwise kill-region. To
make it behave like the shell "
(interactive)
(call-interactively (if (region-active-p)
'kill-region
'backward-kill-word)))
(global-set-key (kbd "C-w") 'backward-kill-word-or-kill-region)
@PuercoPop
PuercoPop / ghc-pkg check
Created April 7, 2013 22:54
The output of ghc-pkg-check
~ $ ghc-pkg check
There are problems in package hint-0.3.3.6:
Warning: library-dirs: /Users/PuercoPop/.cabal/lib/hint-0.3.3.6/ghc-7.4.2 doesn't exist or isn't a directory
Warning: haddock-interfaces: /Users/PuercoPop/.cabal/share/doc/hint-0.3.3.6/html/hint.haddock doesn't exist or isn't a file
Warning: haddock-html: /Users/PuercoPop/.cabal/share/doc/hint-0.3.3.6/html doesn't exist or isn't a directory
dependency "MonadCatchIO-mtl-0.3.0.5-a4c0491a4a7ed8d485833de290967759" doesn't exist
dependency "base-4.5.1.0-47f48c3ae7f8256a66a23e9dfe22eefc" doesn't exist
dependency "directory-1.1.0.2-14f8a11152cd2a14287b62d27ca5dbf3" doesn't exist
dependency "ghc-7.4.2-d3a9dd85237f3f10ee165730595f5f5d" doesn't exist
dependency "ghc-mtl-1.0.1.2-7151af897d6d3639a2be9006df81ce31" doesn't exist
@PuercoPop
PuercoPop / test.py
Created February 6, 2013 17:29
Test case for freezegun that fails
# -*- coding: utf-8 -*-
# To run py.test test.py
from datetime import datetime
from freezegun import freeze_time
class A(object):
def __init__(self):
self.date = datetime.now()
;; Recursive Process
(define (factorial n)
(if (= n 1)
1
(* n (factorial (- n 1)))))
;; Iterative Process
(define (factorial n)
(fact-iter 1 1 n))
(define (fact-iter product counter max-count)
(if (> counter max-count)
(defun backward-kill-word-or-kill-region ()
"When no region is active call backward-kill-word, otherwise kill-region. To
make it behave like the shell "
(interactive (list (point) (mark)))
(if mark-active
(kill-region point mark)
(backward-kill-word 1)))
<iframe id="RSIFrame" name="RSIFrame" scrolling="no" width="305" height="280" allowTransparency="true" frameborder="0" marginheight="0" marginwidth="0"></iframe>
<script type="text/javascript" src="styles/jquery-1.8.2.min"></script>
<script type="text/javascript">
$(document).ready(function() {
var currentUrl= window.location.pathname;
var iframe = document.getElementById("RSIFrame");
var currentPathname = iframe.src
$.ajax({
url: "https://forms.netsuite.com/app/site/crm/externalleadpage.nl",
method: "GET",
//context of TrackingPixelList.txt
var mydata1 = "hello ";
var mydata2 = "fox jumps over ";
var mydata3 = "the lazy dog";
// end of text file
@PuercoPop
PuercoPop / bencode.clj
Created September 30, 2012 23:14
bencoding/decoding functions in clj
(ns clj_torrent.bencode
(:require [clojure.string :as string]))
(defn decode-bstring [bstring]
"Decodes a bencoded string. It ensures the length matches the content."
(let [[length content] (string/split bstring #":" 2)]
(when (= (Integer/parseInt length) (.length content))
content)))
(defn decode-binteger [binteger]
(defadvice zap-to-char (after zap-up-to-char-advice (arg char) activate)
"Kill up to the ARG'th occurence of CHAR, and leave CHAR. If
you are deleting forward, the CHAR is replaced and the point is
put before CHAR"
(insert char)
(if (< 0 arg) (forward-char -1)))