Skip to content

Instantly share code, notes, and snippets.

View svallory's full-sized avatar
:bowtie:
Coding like there's no tomorrow

Saulo Vallory svallory

:bowtie:
Coding like there's no tomorrow
View GitHub Profile
@svallory
svallory / output
Created November 11, 2013 03:56
tsdoc error
exec error: Error: Command failed: js: "/projects/theblacksmith/tsm/lib/tsm/compiler.ts", line 10: missing ; before statement
js: class Compiler
js: .............^
js: "/projects/theblacksmith/tsm/lib/tsm/compiler.ts", line 12: missing ; before statement
js: public filePattern;
js: ...................^
js: "/projects/theblacksmith/tsm/lib/tsm/compiler.ts", line 14: missing ; before statement
js: private compiledModules = [];
js: ........................^
js: "/projects/theblacksmith/tsm/lib/tsm/compiler.ts", line 15: missing ; before statement
namespace Sparrow.Domain.ServiceOrder
{
using System;
using System.Collections.Generic;
using Iesi.Collections.Generic;
using Jack.Core.Domain;
using Jack.Core.Envent;
@svallory
svallory / sass-one-time-importer.rb
Last active December 18, 2015 21:58
Sass custom importer which only imports the same file once. Requires colorize to make it easy to debug. You can remove it safely (but make sure to remove all the .red, .blue etc. calls also)
require 'colorize'
module Liftr
module Importers
class ImportOnce < ::Sass::Importers::FilesystemFilesystem
attr_accessor :root, :debug_level, :staleness_check, :imported, :original_filename
# Creates a new filesystem importer that imports files relative to a given path.
#
@svallory
svallory / hamlphp.render_partial.php
Created June 24, 2013 14:36
How to render a partial using HamlPHP
<?php
// WARNING: This is the simplest possible example. It could be vastly improved
// by keeping the HamlPHP instance somewhere and, even more important, caching parser results
function render_partial($file, $data) {
$parser = new HamlPHP(new FileStorage('path/to/tmp/'));
$content = $parser->parseFile($file);
echo $parser->evaluateFile($content, $data);
}
namespace Sparrow.Migrations
{
using System;
using System.Data.Entity.Migrations;
using System.IO;
public abstract class ScriptMigration : DbMigration
{
public string MigrationsDir
{
public IValidationResult<Relationship> Update(Relationship relationship, IUser author)
{
repository.Attach(relationship);
relationship.UpdaterId = author.Id;
relationship.DeactivatedAt = DateTime.Now;
if (relationship.IsActive)
relationship.IsActive = false;
public IValidationResult<Relationship> Update(Relationship relationship, IUser author)
{
repository.Attach(relationship);
relationship.UpdaterId = author.Id;
relationship.DeactivatedAt = DateTime.Now;
if (relationship.IsActive)
relationship.IsActive = false;
@svallory
svallory / extract_clone_all_script.js
Last active December 12, 2015 04:58
Generate shell script to clone all your repositories, or a configured subset of them from your GitHub Dashboard.
// Instructions:
// 1. Navigate to you GitHub dashboard, either (https://github.com or https://github.com/organizations/{org_name}
// 2. Click on "All repositories" or "Show N more repositories" to show all your repos
// 3. Open Firebug console, and paste this script. Optionally, change the options below
// 4. Run and have fun
var options = {
origin: "all", // can be: source, fork or all
visibility: "all", // can be: public, private or all
showInNewWindow: true
@svallory
svallory / _sass_importers_importonce.rb
Last active December 11, 2015 05:08
Sass custom importer which only imports the same file once, Compass required config and patch.
##
# the ImportOnce importer itself
# colorize is used for colorized terminal output, useful for debugging, but you can strip that off
##
require 'colorize'
module Sass
module Importers
class ImportOnce < Filesystem
@svallory
svallory / gist:3650672
Created September 6, 2012 03:22
AutoMapper Two-way mapping
Mapper.CreateMap<Design, DesignSubmitViewModel>()
.ForMember(d => d.Tags, opt => opt.MapFrom(d => d.Tags.Aggregate("", (total, tag) => total + (tag.Name + ", ")).Trim(' ',',')));
Mapper.CreateMap<DesignSubmitViewModel, Design>()
.ForMember(d => d.Competition, opt => opt.Ignore())
.ForMember(d => d.Tags, opt => opt.MapFrom(d => d.Tags.Split(',').Select(name => new Tag() { Name = name.Trim() })));