Skip to content

Instantly share code, notes, and snippets.

View anztrax's full-sized avatar
🏠
Working from home

andrew ananta anztrax

🏠
Working from home
View GitHub Profile
@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active May 3, 2024 10:41
webRTC stun / turn server list
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
import ApolloClient, { createNetworkInterface } from 'apollo-client';
const networkInterface = createNetworkInterface({ uri: 'http://my-api/graphql' });
const client = new ApolloClient({
networkInterface,
});
export default client;
@andrewluetgers
andrewluetgers / App.js
Last active March 10, 2021 17:39
Image loading with react-konva
import React, { Component } from 'react';
import DevTools from 'mobx-react-devtools';
import Konva from 'konva';
import {Stage, Layer, Rect, Line, Image} from 'react-konva';
import Img from './Img/Img.js';
import './App.css';
import pg from '../assets/scribo-doc-dia-00008061.json'
console.log(pg);
@deanmcpherson
deanmcpherson / alignment.css
Created June 16, 2016 07:54
Text alignment -> draftjs workaround
.alignment--left {
.public-DraftStyleDefault-block {
text-align; left;
}
}
.alignment--center {
.public-DraftStyleDefault-block {
text-align; center;
}
}
anonymous
anonymous / memory.rs
Created March 6, 2016 17:36
use std::collections::BTreeMap;
use std::mem;
use std::ptr;
const LIVE: usize = 1 << 16;
const BLOCK: usize = 1 << 9;
/// An unmanaged pointer to a managed object.
pub type Pointer = *mut usize;
@sgnl
sgnl / postgres-brew.md
Last active April 21, 2024 23:18
Installing Postgres via Brew (OSX) (outdated see top most note)

Outdated note: the process is a lot easier now: after you brew install postgresql you can initialize or stop the daemon with these commands: brew services start postgresql or brew services stop postgresql.

new out put may look like

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
@jquense
jquense / 0. intro.md
Last active September 24, 2022 05:10
Alternative ways to define react Components

The 0.13.0 improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The main thing of note in 0.13 is that React Components are no longer special objects that need to be created using a specific method (createClass()). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!

Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&amp;%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component for setState(), but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props and context to the component instance otherwise the component will be static. The reason is

@petehunt
petehunt / React sortable
Created December 9, 2013 22:30
Here's an example of React + jQuery UI sortable. The key thing to note is that we have the render() method do absolutely nothing and use componentDidUpdate() + React.renderComponent() to proxy updates through to the children. This lets us manage the DOM manually but still be able to use all the React goodies you know and love.
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
</head>
@mystix
mystix / dedupe.js
Last active May 19, 2018 08:02
[JavaScript] Remove duplicate occurences of string within string
// adapted from http://stackoverflow.com/a/13486540
function dedupe(str, delimiter) {
return str.split(delimiter || ',').reverse().filter(function(e, i, arr) {
return arr.indexOf(e, i+1) === -1;
}).reverse();
}
@ksafranski
ksafranski / Common-Currency.json
Last active April 22, 2024 15:16
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},