Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / reflection.go
Created June 26, 2016 21:46 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
var gulp = require('gulp');
var connect = require('gulp-connect');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
gulp.task('connect', function() {
connect.server({
root : __dirname
});
});
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
var http = require('http');
var ecstatic = require('ecstatic');
gulp.task('default', function() {
http.createServer(
ecstatic({ root: __dirname })
).listen(8000);
@chris-ramon
chris-ramon / killatom.go
Last active August 29, 2015 14:15 — forked from y-abe/killatom.go
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"strconv"
)
str := fmt.Sprintf(`{"key": "%s", "message": {"html": "%s", "text": "%s", "subject": "%s", "from_email": "%s", "from_name": "%s", "to": [ { "email": "%s", "name": "%s", "type": "%s" }]}}`,
s.Key,
s.Message.Html,
s.Message.Text,
s.Message.Subject,
s.Message.FromEmail,
s.Message.FromName,
s.Message.To[i].Email,
s.Message.To[i].Name,
s.Message.To[i].RType)
config(function($httpProvider) {
$httpProvider.interceptors.push('cacheSlayer');
})
.factory('cacheSlayer', function($injector, $q) {
return {
request: function(config) {
if (config.method === 'GET' && /^\/api/.test(config.url)) {
var sep = config.url.indexOf('?') === -1 ? '?' : '&';
config.url = config.url + sep + 'cacheSlayer=' + new Date().getTime();
}
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.
package event
import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/suite"
@chris-ramon
chris-ramon / utils.go
Last active August 29, 2015 14:11 — forked from Luit/utils.go
package utils
func Slugify(title string) string {
var slug []byte
for _, x := range title {
switch {
case ('a' <= x && x <= 'z') || ('0' <= x && x <= '9'):
slug = append(slug, byte(x))
case 'A' <= x && x <= 'Z':
package main
import (
"encoding/xml"
"net/http"
"net/url"
"fmt"
"strings"
"io/ioutil"
"encoding/json"