Skip to content

Instantly share code, notes, and snippets.

View saluber's full-sized avatar
🙃

Samantha Luber saluber

🙃
View GitHub Profile
@velicast
velicast / stdc++.h
Created July 17, 2013 17:56
Linux GCC 4.8.0 /bits/stdc++.h header definition.
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@artyom
artyom / epoll.go
Created November 1, 2013 12:21
Using epoll from Go.
package main
import (
"log"
"os"
"syscall"
)
func main() {
f, err := os.Open("/tmp/pipe")
@nandor
nandor / redblack.cc
Created February 27, 2014 12:50
C++ Red-Black Trees (Based on CLR: Introduction to Algorithms)
#include <cstdlib>
#include <stdexcept>
#include <iostream>
using namespace std;
template<typename Key, typename Value>
class RedBlack
{
public:
RedBlack()
@nageshs
nageshs / JsonModel.java
Last active August 14, 2023 19:52
Sample to get structureInfo from NestdataModel
package com.example.nestapi;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
@maxfenton
maxfenton / macos_defaults.md
Last active November 8, 2023 23:57
Mac system defaults tricks

System stuff for a mac

What the defaults do and how to undo them

Dropshadows on screenshots

defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer

Convert .cer certificate exported from Keychain.app to PEM format:

openssl x509 -inform der -outform pem -in moonist-ca.cer -out moonist-ca.pem

Convert .p12 bundle (certificate + key) exported from Keychain.app to PEM format:

openssl pkcs12 -in grafana.p12 -out grafana.pem -nodes

Then split resulting pem file into two separate files (certificate and key) using text editor.

import { createStore, applyMiddleware } from 'redux';
import { Observable, Subject } from 'rxjs';
const api = type => {
console.log(`calling API ${type}`);
return new Promise(res => setTimeout(() => res(), 500));
};
const actionOrder = (actions, order) => actions.every((action, index) => action.type === order[index]);
const actionPredicate = actions => filterableAction => actions.some(action => action === filterableAction.type);
@btroncone
btroncone / ngrxintro.md
Last active June 26, 2024 08:27
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@gund
gund / http-interceptor-concept.md
Last active September 19, 2022 01:08
Concept of Http Interceptor for Angular 2

First, we need to define interfaces with which we will work:

export interface Interceptable<T extends Interceptor<any, any>> {
  addInterceptor(interceptor: T): Interceptable<T>;
  removeInterceptor(interceptor: T): Interceptable<T>;
  clearInterceptors(interceptors?: T[]): Interceptable<T>;
}

export interface Interceptor<T, D> {
@SimplGy
SimplGy / renameToHash.sh
Last active July 27, 2023 07:30
Rename files with a hash based on their contents. eg: `abc.jpg` to `3101ace8db9f.jpg`. Useful for detecting duplicates.
#!/bin/bash
# TODO: skip tiny files (so small they couldn't be photos)
# TODO: make sure sym links and other file system oddities are handled
# TODO: look at paralellization for perf boost
#
# Constants
#
CHAR_COUNT=12
BLOCK_COUNT=6