Skip to content

Instantly share code, notes, and snippets.

View st8998's full-sized avatar

Ivan Efremov st8998

View GitHub Profile
package main
import (
"bytes"
"encoding/json"
"fmt"
"os"
)
type ManifestItem struct {

Keybase proof

I hereby claim:

  • I am st8998 on github.
  • I am st8998 (https://keybase.io/st8998) on keybase.
  • I have a public key ASDFRm_i7IWAvAiUln9xt4CkIyT5FsQXWzsP9nYpEDPKNQo

To claim this, I am signing this object:

import { eventChannel } from 'redux-saga'
import { take, spawn, put, takeLatest, takeEvery, call } from 'redux-saga/effects'
import { isEmpty } from 'ramda'
import * as actions from './auth_actions'
const provider = new firebase.auth.GoogleAuthProvider()
const authStateChannel = eventChannel((emit) => {
firebase.auth().onAuthStateChanged((user) => {
const cheerio = require('cheerio')
const request = require('request')
const fs = require('fs')
const { map, join, stringify, readable } = require('event-stream')
const BASE_URL = 'http://www.profjournal.com/update2016/article_page_new.cfm'
const SUBID = 110890
const START_ID = 74371 //81209//468
import { map, is, filter, keys, compose, identity, join } from 'ramda'
const processObj = compose(classnames, keys, filter(identity))
const processArr = compose(join(' '), filter(identity), map(classnames))
function classnames (arg) {
switch (true) {
case is(String, arg): return arg
case is(Array, arg): return processArr(arg)
@connect(
(state, props) => ({ user: find(propEq('id', Number(props.params.id)), state.users) }),
{ requestUser }
)
export default class UserProfile extends Component {
static contextTypes = {
router: React.PropTypes.object
};
componentWillMount() {
@st8998
st8998 / header.js
Last active March 28, 2016 15:03
Container component with loading
import './header.css'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { find, propEq, assoc, compose, __ } from 'ramda'
import { createSelector } from 'reselect'
import { requestCurrent as requestCurrentUser } from 'users/users_actions'
import Transition from 'misc/transition'
import Loader from 'loader/loader'
import { default as randomStr } from 'randomatic'
export default function register() {
return this.directive('radiogroup', /* @ngInject */ function () {
return {
restrict: 'A',
require: ['ngModel'],
scope: true,
controller() {},
@st8998
st8998 / 1.rb
Last active February 29, 2016 13:47
class DefaultAvatarController < ApplicationController
respond_to :svg
COLORS = %w( #ff658c #fa80db #d185ee #b385f5 #7075ef #5098ea #a8b6cc #03bee9 #00bdb3
#00d590 #a0d930 #f3cb00 #efc47b #ff9740 #d8965b #ff755a #3e464e )
def avatar
model = params[:model_name].capitalize.constantize.find(params[:id])
@abbr = model.name.match(/(?:\s*(\w).*?\s+(\w).*)|(?:^\s*(\w)(\w).*)|(\w)/).to_a[1..-1].join('').upcase
@color = COLORS[model.id % COLORS.size]
// imperative way
function rangeMonths(start, end) {
const out = []
for(let curr = moment(start), mEnd = moment(end); curr.isBefore(mEnd); curr.add(1, 'day'))
if (curr.date() === 1)
out.push(curr.format())
return out
}
const months = rangeMonths('2015-01-01', '2015-10-01')