Skip to content

Instantly share code, notes, and snippets.

View krayfaus's full-sized avatar
🌼
Overthinking modular design

Krayfaus krayfaus

🌼
Overthinking modular design
View GitHub Profile
@stephenlb
stephenlb / 1.html
Last active October 27, 2018 05:10 — forked from ToeJamson/1.js
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<script src=http://cdn.pubnub.com/pubnub.min.js></script>
<script>(function(){
var pubnub = PUBNUB.init({publish_key:'demo',subscribe_key:'demo',ssl:true});
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chat';
@antxd
antxd / index.html
Created June 28, 2019 16:01
Maintenance Page
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="robots" content="noindex"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
@John07
John07 / HLS_to_mp4
Last active October 11, 2020 01:20
Save/record HTTP Live Stream (short HLS, the kind of live stream that can be played by iOS devices) to disk as mp4 file
ffmpeg -re -i http://url.com/playlist.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
@hamaluik
hamaluik / cppLinearInterpolator
Created January 15, 2013 04:53
Basic linear interpolator class in C++
#include <map>
#include <vector>
/**
* Provides a basic interpolation mechanism in C++ using the STL.
* Maybe not the fastest or most elegant method, but it works (for
* linear interpolation!!), and is fast enough for a great deal of
* purposes. It's also super easy to use, so that's a bonus.
*/
class LinearInterpolator {
@pmarrapese
pmarrapese / bluebird-vs-native.md
Created May 15, 2016 00:32
Bluebird vs. Native Promises

Bluebird vs. Native Promises

Stack traces

Native

"use strict";

function doAsyncThing() {
  let p = new Promise((resolve, reject) => process.nextTick(resolve)).then(() => {
 console.log('after resolve', new Error().stack);
@kotarella1110
kotarella1110 / Bad.jsx
Last active April 27, 2021 16:49
Best way to define styled-components
import React from 'react';
import styled from 'styled-components';
const Title = styled.h1`
font-size: 1.5em;
text-align: center;
color: palevioletred;
`;
const Wrapper = styled.section`

Best / our practise on writing styled components

📖 Documentation

👮🏻 Conventions

Know your components. Look at existing components before you create a brand new one. It is really fun to create new components but please ask yourself or the designer if we already have a component that might do the job first! Maybe you can create a variant of an existing component or just use it out of the box? It is important to evaluate the complexity of creating a variant. Sometimes it is smarter to create a new component. Discuss with your teammates!

DRY - Don't repeat yourself - Use inheritance to share style between similar components.

@jouyouyun
jouyouyun / detect_kbd_devices.c
Created May 25, 2017 02:36 — forked from mmn80/detect_kbd_devices.c
Uses libudev to detect all keyboard input event devices (/dev/input/eventX). Based on the /usr/lib/udev/findkeyboards script.
#include <libudev.h>
#define MAX_KBD_DEVICES 10
const char** detect_kbd_devices()
{
const char **devnodes = calloc(MAX_KBD_DEVICES, sizeof(char*));
struct udev *udev;
struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device *dev;
@carl0zen
carl0zen / styled-components-mixin-example.jsx
Last active December 8, 2021 05:51
Styled Components Mixin example
// Mixin like functionality
const textInput = props => `
color: ${props.error ? color.white : color.base};
background-color: ${props.error ? color.alert : color.white};
`;
export const Input = styled.input`
${textInput}
`;
@cameronp98
cameronp98 / hexdump.c
Last active July 28, 2022 16:24
Hex dump program in C (only tested in windows 7)
/* usage: hexdump <file-in> [file-out] */
#include <stdio.h>
#define CHUNK 16
FILE *hexdump_open(const char *path, const char *mode) {
FILE *fp;
if (!(fp = fopen(path, mode))) {
printf("error opening '%s'", path);