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
import ApolloClient, { createNetworkInterface } from 'apollo-client';
const networkInterface = createNetworkInterface({ uri: 'http://my-api/graphql' });
const client = new ApolloClient({
networkInterface,
});
export default client;
@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();
}
@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>
@vkarpov15
vkarpov15 / index.js
Created April 25, 2019 23:51
Hello, Imports with `package.json`
import test from './test.js';
test();
@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;
}
}
@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);
// https://binarysearch.com/problems/Edges-that-Disconnect-the-Graph
import java.util.*;
class Solution {
static class Result {
int lowLink;
boolean isCycle;
Result(int lowLink, boolean isCycle) {
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;
@blachniet
blachniet / k8s.conf
Created May 21, 2020 03:52
Ansible playbook to install Minikube on a VM with the "none" driver. Add your inventory in a file named `hosts`, then execute the playbook with `ansible-playbook --ask-become-pass -i hosts ./playbook.yml`
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
# How to echobot with XMPP, BOSH, and Strophe
1. Setup ejabberd(http://www.ejabberd.im/) server and setup account admin@localhost.local
NOTE: localhost should be enough. If you setup something else, make sure you add it at /etc/hosts like this
#/etc/hosts
127.0.0.1 localhost.local
NOTE: Also download Psi(http://psi-im.org/), and make sure you can connect to your ejabberd server.
2. Download strophe(http://code.stanziq.com/strophe/) and place it (eg: /Users/makoto/work/sample/strophejs-1.0)