Skip to content

Instantly share code, notes, and snippets.

View s-panferov's full-sized avatar

Stanislav Panferov s-panferov

View GitHub Profile
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/Dawn.tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
".tags*",
"*.pyc",
package main
import (
"bufio"
"fmt"
"net"
)
func handleConnection(conn net.Conn) {
fmt.Println(conn)
@s-panferov
s-panferov / SassMeister-input.scss
Created August 8, 2014 13:38
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
@media mobile {
@media(min-aspect-ratio: 8/5){
.b-bg_logo{
width: 18vh;
height: 6vh;
@s-panferov
s-panferov / result.ts
Created November 19, 2014 14:11
Result type in TypeScript
interface Result<T, E> {
map<U>(fn: (a: T) => U): Result<U, E>;
mapErr<U>(fn: (a: E) => U): Result<T, U>;
isOk(): boolean;
isErr(): boolean;
ok(): Option<T>;
err(): Option<E>;
and<U>(res: Result<U,E>): Result<U,E>;
andThen<U>(op: (T) => Result<U,E>): Result<U,E>;
@s-panferov
s-panferov / class_manager.ts
Last active August 29, 2015 14:10
BEM ClassManager
module classes {
export interface ClassManager {
mod(...name: string[]): ClassManager;
cmod(condition: boolean, ...name: string[]): ClassManager;
toString(): string;
before(...other: ToString[]): ClassManager;
after(...other: ToString[]): ClassManager;
}
@s-panferov
s-panferov / option.ts
Created November 30, 2014 12:15
Option and Result types from Rust in TypeScript
interface Option<T> {
map <U>(fn: (a: T) => U): Option<U>;
isSome(): boolean;
isNone(): boolean;
isSomeAnd(fn: (a: T) => boolean): boolean;
isNoneAnd(fn: () => boolean): boolean;
unwrap(): T;
unwrapOr(def: T): T;
unwrapOrElse(f: () => T): T;
map<U>(f: (a: T) => U): Option<U>;

Hi all, can somebody help me to rewrite this piece of code with new unboxed closures:

struct Builder;
pub fn build(rules: |params: &mut Builder|) -> Builder {
    let mut builder = Builder::new();
    rules(&mut builder);

    builder
}
var convertSM = require('convert-source-map');
var fs = require('fs');
var rewrite = require('connect-modrewrite');
module.exports = function (grunt) {
grunt.registerTask('tsmap', function() {
var existingMap;
var fileName = process.cwd() + '/dist/app.js';
var fileContent = fs.readFileSync(fileName).toString();
var viewClass = bemr.block("card");
return DOM.div({className: viewClass},
DOM.div({className: viewClass.el("cover")},
avatar.AvatarF({
url: "/public/profile.png",
variant: avatar.Variant.Large,
className: viewClass.el("avatar")
}),
DOM.div({className: viewClass.el("name")}, user.name)
private dispatchLoadOrgs(action: org_actions.LoadOrgs.Start) {
loadOrgsLock.lock(action.actionId, api.requestManager);
org_api.OrgApi
.loadOrgs(action.actionId)
.then((reply) => {
loadOrgsLock.unlock();
this.dispatcher.dispatch(new org_actions.LoadOrgs.Complete(action, reply.orgs))
})
.catch((e) => {