Skip to content

Instantly share code, notes, and snippets.

@hdeshev
hdeshev / .ctags
Created October 9, 2011 21:58
My Scala-enabled ctags config
--langdef=scala
--langmap=scala:.scala
--regex-scala=/^[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\1/c,classes/
--regex-scala=/.*class[ \t]+([a-zA-Z0-9_]+)/\1/c,classes/
--regex-scala=/^[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\1/t,traits/
--regex-scala=/.*trait[ \t]+([a-zA-Z0-9_]+)/\1/t,traits/
--regex-scala=/^[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
--regex-scala=/^[ \t]*def[ \t]+([a-zA-Z0-9_\?]+)/\1/m,methods/
--regex-scala=/^[ \t]*val[ \t]+([a-zA-Z0-9_]+)/\1/C,constants/
--regex-scala=/^[ \t]*var[ \t]+([a-zA-Z0-9_]+)/\1/l,local variables/
@hdeshev
hdeshev / javap.txt
Created October 11, 2011 08:00
Scala structural types implemented with reflection
scala> :javap Greeter -c
Compiled from "<console>"
public class Greeter extends java.lang.Object implements scala.ScalaObject{
public static {};
Code:
0: iconst_0
1: anewarray #8; //class java/lang/Class
4: putstatic #14; //Field reflParams$Cache1:[Ljava/lang/Class;
7: new #16; //class java/lang/ref/SoftReference
10: dup
class User < ActiveRecord::Base
has_file :avatar, AvatarUploader
validates_file_extension_of :avatar, :allowed => ["jpg", "png"]
end
@hdeshev
hdeshev / processing.scala
Created March 3, 2012 10:10
Render a Processing (http://processing.org) scene to an image
//Invoke with: scala -cp /opt/processing-1.5.1/lib/core.jar processing.scala
import processing.core._
import java.io._
import java.awt.image._
import javax.imageio._
class Image extends PApplet {
private[this] val width = 200
private[this] val height = 200
@hdeshev
hdeshev / Client.scala
Created March 6, 2012 20:20
My own mailer wannabe inspired by Lift mailers
object AuthMailer extends Mailer {
def sendWelcomeEmail(account: Account)(implicit settings: MailerSettings) {
val subject = "[Progstr Filer] Welcome to Progstr Filer!"
send(
From("support@mysite.com", "Mysite Support"),
To(account.email -> account.name),
Subject(subject),
HtmlTemplate("welcome-html",
'name -> "Hristo", 'subject -> subject, 'account -> account),
TextTemplate("welcome-text",
@hdeshev
hdeshev / PowerShell-remoting.md
Created March 16, 2012 18:42
Enable PowerShell remoting

Setting up PowerShell remoting.

First, you need to install PowerShell version 2.

Enabling remoting on the server machine

Log in to the server machine, start PowerShell as an administrator and execute:

Enable-PSRemoting
@hdeshev
hdeshev / set_attributes.py
Created August 24, 2012 12:12 — forked from skanev/set_attributes.py
Set arguments passed to the constructor as attributes
import inspect
from functools import wraps
def set_attributes(constructor):
@wraps(constructor)
def wrapped(self, *args, **kwargs):
names = inspect.getargspec(constructor).args
for (key, value) in dict(zip(names[1:], args)).items():
setattr(self, key, value)
for (key, value) in kwargs.items():

For maximum Python 2.x -> Python 3 compatibility:

from future import absolute_import, division, print_function, unicode_literals

@hdeshev
hdeshev / .ctags-css
Last active May 4, 2017 17:01
ctags extras
--langdef=css
--langmap=css:.css
--langmap=css:+.scss
--langmap=css:+.sass
--langmap=css:+.styl
--langmap=css:+.less
--regex-css=/^[ \t]*(([A-Za-z0-9_-]+[ \t\n,]+)+)\{/\1/t,tag,tags/
--regex-css=/^[ \t]*#([A-Za-z0-9_-]+)/#\1/i,id,ids/
--regex-css=/^[ \t]*\.([A-Za-z0-9_-]+)/\1/c,class,classes/
ninja_required_version = 1.6
tsflags = --module commonjs --noEmitOnError --noImplicitAny --emitDecoratorMetadata --experimentalDecorators --target es5
rule tsc
command = ./node_modules/.bin/tsc $tsflags "$in" && node build/getrefs.js "$in" "$out" "$in.dep"
description = TypeScript compile: $in
depfile = "$in.dep"
deps = gcc
rule dts
command = touch "$out"
description = TypeScript declarations: $in