Skip to content

Instantly share code, notes, and snippets.

Avatar

Stanislav Panferov s-panferov

View GitHub Profile
View gist:4690873
{
"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",
View gist:8423402
package main
import (
"bufio"
"fmt"
"net"
)
func handleConnection(conn net.Conn) {
fmt.Println(conn)
@s-panferov
s-panferov / SassMeister-input.scss
Created Aug 8, 2014
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// 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 Nov 19, 2014
Result type in TypeScript
View result.ts
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 Aug 29, 2015
BEM ClassManager
View class_manager.ts
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 Nov 30, 2014
Option and Result types from Rust in TypeScript
View option.ts
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>;
View gist:e9cafbec6ef5d097f041

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
}
View gist:476edf52f425a8e12671
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();
View DOM.ts
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)
View API.ts
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) => {