Skip to content

Instantly share code, notes, and snippets.

@alpox
alpox / main.cpp
Last active October 8, 2016 22:34
u2_cpp_ex5
#include <iostream>
#include <sstream>
#include "pvector.h"
using namespace std;
template <typename T>
inline pair<T, T> getCalcValues(pvector<T> &rpnStack) {
@alpox
alpox / Dockerfile
Created February 10, 2017 16:36
Docker file for elixir
# Pull base image.
FROM ubuntu:14.04
# Install.
RUN \
sudo sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
sudo apt-get update && \
sudo apt-get install -y wget && \
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb && \
sudo apt-get update && \
const sumFibs=(num)=>(fib=((s,l=0,n=1,m=0)=>(n%2?n<=s&&(m+=n)&&0:0)||n>s?m:fib(s,n,l+n,m)))(num);
sumFibs(1000);
const { transformFactory } = require('../utils/stream');
const { GENERATED_AT_TIME } = require('../utils/constants');
module.exports = transformFactory((stream, config, transform) => data => {
const transformed = transform(data);
const id = transformed[0].subject;
const graph = transformed.reduce(
(acc, triple) => {
acc[triple.predicate] = { '@id': triple.object };
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Collections;
using System.Threading;
using System.Threading.Tasks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Text.RegularExpressions;
namespace UNIMotor
@alpox
alpox / useReduxReducer.js
Created November 27, 2020 20:59
Hook: useReduxReducer
function useReduxReducer(reducer, initialState, initializer, middleware) {
const lastState = useRef(initialState)
const enhancedReducer = (state, action) => lastState.current = reducer(state, action)
const [state, dispatchOriginal] = useReducer(
enhancedReducer,
initialState,
initializer
);
const cl = (e,a,s=[...new Set(e)],l=s.length,n=(i,v)=>v>=s[i]?n(i-1,v):i)=>a.reduce(([c,i],v,_,__,ni=n(i,v))=>[(c.push(ni+2),c),ni],[[],l-1])[0];
@alpox
alpox / useThumbnailRail.js
Last active May 16, 2021 15:43
useThumbnailRail
const useThumbnailRail = (items, slideChange, active, width) => {
const [springs, api] = useSprings(items.length, i => ({
x: i * getWindowWidth(),
}))
const index = useRef(active)
const lastIndex = useRef(active)
const correct = useCallback(
(i, down) => (result, controller) => {
@alpox
alpox / asyncAwait.js
Created February 27, 2022 21:42
Async await
const asyncFun = fun => (...args) => {
const gen = fun(...args);
return drain(gen);
}
function ensurePromise(maybePromise) {
return maybePromise.then
? maybePromise
: Promise.resolve(maybePromise);