Skip to content

Instantly share code, notes, and snippets.

@ryepup
ryepup / interpolate-static.php
Created February 9, 2015 21:25
php string interpolate static member
class Temp {
public static $key = "FOO";
public static function template(){
return "foo ". self::$key . " bar"; // works if you don't use string interpolation
return "foo self::$key bar"; // Undefined variable: key
return "foo {self::$key} bar"; // Undefined variable: key
return "foo ${self::$key} bar"; // Undefined variable: FOO
return "foo {Temp::$key} bar"; // Undefined variable: key
return "foo $key bar"; // Undefined variable: key
@ryepup
ryepup / deploy-com-dll.targets
Last active August 29, 2015 14:07
snippet of MSBuild for publish COM objects to a remote server using psexec
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Env)' == 'test'">
<!-- UNC path where we publish code-->
<PublishFolder>\\dev-server\Sites\my-classic-asp-site</PublishFolder>
<!-- the remote path to where our code is deployed -->
<LocalPublishFolder>D:\WebRoot\my-classic-asp-site</LocalPublishFolder>
<!-- the computer name for psexec -->
<Computer>\\dev-server</Computer>
@ryepup
ryepup / gist:6342577
Last active December 21, 2015 17:48 — forked from tkellogg/gist:5619461
installing mono3 and monodevelop4
# Add this line to your software sources
deb http://debian.meebey.net/experimental/mono /
sudo apt-get update
# of course, apt-get remove mono-complete first...
sudo apt-get install mono-complete
# I installed monodevelop from apt just to get all the prereqs
sudo apt-get install monodevelop
@ryepup
ryepup / index.html
Last active December 19, 2015 22:49
very simple development log app in angular; a poor-mans one-note or org-mode
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="utf-8">
<title>Dev log</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div class="container" ng-controller="DevLogController">
<h2>Dev Log</h2>
#!/bin/bash
#read from emacs server file what port it is currently listening on
PORT=`egrep -o '127.0.0.1:([0-9]*)' ~/.emacs.d/server/server | sed 's/127.0.0.1://'`
HOST="${@: -1}"
echo "Found host '$HOST'"
ssh "$HOST" "mkdir -m 700 -p ~/.emacs.d/server"
scp -p ~/.emacs.d/server/server $HOST:.emacs.d/server/server
@ryepup
ryepup / sbclrc.lisp
Created October 19, 2012 16:00
Generate TAP files using lisp-unit, ASDF, and with-test-listener
(defmethod asdf:perform :around ((o asdf:test-op) (system asdf:system))
;; find a good filename, inside the current Jenkins workspace
(let ((outfile
(merge-pathnames (format nil "TAP/~a.tap" (asdf:component-name system))
(truename (sb-ext:posix-getenv "WORKSPACE"))))
;; keep a list of how many tests we've got
(num-tests 0)
;; keep a list of test names and how many assertions passed
(working-tests (make-hash-table)))
(ensure-directories-exist outfile)
@ryepup
ryepup / gist:714424
Created November 24, 2010 21:12
testing syntax for a simpy lisp port
;; from SimPy.Simulation import *
;; class Message(Process):
;; """ a simple Process """
;; def __init__(self,i,len):
;; Process.__init__(self,name="Message"+str(i))
;; self.i = i
;; self.len = len
;; def go(self):
@ryepup
ryepup / gist:708502
Created November 21, 2010 06:04
coroutines with bordeaux-threads (broken)
(defmacro make-coroutine ((&key (coroutine-done-value :done)) &body body)
(alexandria:with-gensyms ((yield-cv "can we yield?")
(run-cv "can we run?")
(run-lck "lock for the runner thread")
(val "yielding value")
(thrfn "thread body"))
`(let* ((,yield-cv (bordeaux-threads:make-condition-variable
:name "yield"))
(,run-cv (bordeaux-threads:make-condition-variable
:name "run"))
@ryepup
ryepup / gist:708501
Created November 21, 2010 06:04
coroutines with chanl
(defmacro make-coroutine ((&key (coroutine-done-value :done)) &body body)
(alexandria:with-gensyms ((thrfn "thread body")
(c "channel"))
`(let* ((,c (make-instance 'chanl:bounded-channel))
(,thrfn (lambda ()
(flet ((yield (&optional n)
(chanl:send ,c n)))
,@body
(yield ,coroutine-done-value)))))
(let ((alive-p T) val thr)
@ryepup
ryepup / gist:708500
Created November 21, 2010 06:03
coroutine test function
(defun coroutine-test ()
(let ((cor (make-coroutine (:coroutine-done-value :done)
(yield 1)
(yield)
(yield 4))))
(assert (eql 1 (funcall cor)) )
(assert (null (funcall cor)))
(assert (eql 4 (funcall cor)))
(assert (eql :done (funcall cor)))
(assert (eql :done (funcall cor)))))