Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Having fun

Alexander Fallenstedt Fallenstedt

:octocat:
Having fun
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@gh0st026
gh0st026 / docker_export_postgre_table.sh
Last active Jun 23, 2021
Dump PostgreSQL Table in docker container as CSV file
View docker_export_postgre_table.sh
CONTAINER="name"
DB="Db name"
TABLE="Table Name"
FILE="file.csv"
sudo docker exec -u postgres ${CONTAINER} psql -d ${DB} -c "COPY ${TABLE} TO STDOUT WITH CSV HEADER " > ${FILE}
@DomiR
DomiR / observable-queue.ts
Created Mar 11, 2018 — forked from evxn/observable-queue.ts
Add Observable-like entities to a queue (Promises, Observables, Subjects, Arrays, generators, Iterables). After each stream is completed (i.e. Promise resolved) it's elements are emitted to the result stream in the order of addition (first in first out). Each subscriber receives result only for items added to queue after the subscription.
View observable-queue.ts
import {Subject} from 'rxjs/Subject';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Observable, ObservableInput} from 'rxjs/Observable';
import {concatMap, switchMap} from 'rxjs/operators';
enum QueueActions {
RESET = 'RESET',
ADD = 'ADD',
}
@phuochau
phuochau / sample_configuration.js
Last active Mar 26, 2018
Sample configuration for using Jest and vue-test-utils in nuxt.js project
View sample_configuration.js
// package.json
"jest": {
"roots": [
"<rootDir>/tests/unit"
],
"moduleNameMapper": {
"[\\s\\S]*.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/unit/__mocks__/fileMock.js",
"[\\s\\S]*.(css|less)$": "<rootDir>/tests/unit/__mocks__/styleMock.js",
"~/([a-zA-Z0-9/.\\-_]*)": "<rootDir>/src/$1"
@ernsheong
ernsheong / access-mac-localhost-from-parallels-desktop-ie-edge.md
Last active Jul 14, 2021
Accessing macOS localhost from Parallels Desktop IE or Edge
View access-mac-localhost-from-parallels-desktop-ie-edge.md

Access macOS localhost from IE or Edge within Parallels Desktop

This issue is so infuriating that I'm going to take some time to write about it.

  1. MOST IMPORTANT. Your local development server must be bound to IP address 0.0.0.0. Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g. polymer serve --hostname domain.local, hugo serve --bind 0.0.0.0. If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at 0.0.0.0.

  2. My Parallels setting is using Shared Network, nothing special there.

  3. Open macOS Terminal and type ifconfig. Look for the value under vnic0 > inet. It is typically 10.211.55.2.

@brien-crean
brien-crean / twitter_oauth_user_context.js
Created Jul 14, 2017
Twitter 3 legged OAuth on AWS Lambda with NodeJS
View twitter_oauth_user_context.js
const OAuth = require('oauth');
const Twit = require('twit');
const nconf = require('nconf');
// temp global var
var oAuthTokenSecret;
// load config file which contains twitter app tokens
nconf.file({ file: './config/twitter-share.json' }).env()
View random_image_generator.exs
defmodule Image do
defstruct [:grid, :pixel_map]
end
defmodule RandomImageGenerator do
def create(width, bar_size, filename \\ "out.png") do
%Image{}
|> create_grid(width)
|> build_pixel_map(width, bar_size)
@dews
dews / Limit mac bandwidth.md
Last active Jul 12, 2021
Limit mac bandwidth
View Limit mac bandwidth.md

Mac limit bandwidth

Enable firewall

Apple menu -> System Preferences -> Security & Privacy -> Firewall

sudo pfctl -e

Example

sudo dnctl pipe 1 config bw 10Kbit/s
View EmittingComponent.js
import React from 'react'
import mrEmitter from '../helpers/mrEmitter'
export default class EmittingComponent extends React.Component {
handleClick = () => {
mrEmitter.emit('onSomeEvent', 'foo sends bar')
}
render() {
@vespertilian
vespertilian / conditional_effects.ts
Created Feb 9, 2017
Two options for conditional ngrx effects
View conditional_effects.ts
@Effect()
selectAndLoadStore$: Observable<Action> = this.actions$
.ofType(storeActions.SELECT_AND_LOAD_STORE)
.withLatestFrom(this.store.select(ngrx.storeState))
.map(([action, storeState]) => [action.payload, storeState])
.switchMap(([storeName, storeState]) => {
const existsInStore = Boolean(storeState.urlNameMap[storeName]);
return Observable.if(
() => existsInStore,
Observable.of(new storeActions.SetSelectedStore(storeName)),