Skip to content

Instantly share code, notes, and snippets.

View levlaz's full-sized avatar

Lev Lazinskiy levlaz

View GitHub Profile
/**
Enable event sampling. When set to the default of zero, sampling is disabled and all events are sent back to LaunchDarkly.
When set to greater than zero, there is a 1 in samplingInterval chance events will be will be sent.
Example: if you want 5% sampling rate, set samplingInterval to 20.
**/
var ldclient = LDClient.initialize('YOUR_CLIENT_SIDE_ID', user, options = {
samplingInterval: 20
});
@levlaz
levlaz / ld.java
Created April 17, 2018 11:07
Java Sample Code
import com.launchdarkly.client.*;
LDClient ldClient = new LDClient("YOUR_SDK_KEY");
LDUser user = new LDUser.Builder("some_id")
// // 100% Optional
.firstName("Ernestina")
.lastName("Evans")
.email("[email protected]")
@levlaz
levlaz / docker-compose.yml
Created August 30, 2018 15:31
LD Relay Daemon Mode example
version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
relay:
image: launchdarkly/ld-relay
depends_on:
import Layout from '../components/MyLayout.js'
import fetch from 'isomorphic-unfetch'
const Index = (props) => (
<Layout>
<h1>Features</h1>
<ul>
{props.featureKeys.map((key, index) => (
<li key={key}>
{key} is {props.features[key]}
const express = require('express')
const next = require('next')
const Featureflow = require('featureflow-node-sdk');
const LaunchDarkly = require('ldclient-node');
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const ldclient = LaunchDarkly.init(process.env.LD_SDK_KEY)
@levlaz
levlaz / programming_styles.py
Created April 12, 2019 19:36
Python Three Ways
"""
Python three ways
Print the numbers 1 - 10 in procedural, functional, and
object oriented styles.
"""
# Procedural
print(1)
print(2)
@levlaz
levlaz / git.md
Created July 2, 2019 02:35
Git Cheat Sheet

Force SSH for Git Checkout

This comes up when you do go get with a private repo; it wants a username/pass instead of using your key.

git config --global url.ssh://[email protected]/.insteadOf https://github.com/
@levlaz
levlaz / vscode.md
Created July 2, 2019 02:36
VS Code Config Notes

Add vertical ruler

This is helpful to see when you are about to go over 80 characters.

In settings.json

{
    "editor.rulers": [80]
}
@levlaz
levlaz / ubuntu.md
Last active July 11, 2019 02:51
Ubuntu Init Notes

Add New User

adduser $USERNAME

Make vim default editor

sudo update-alternatives --config editor
@levlaz
levlaz / main.java
Created July 24, 2019 23:52
Java Relay Snippet
import com.launchdarkly.client.LDClient;
import com.launchdarkly.client.LDConfig;
import com.launchdarkly.client.LDUser;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import static java.util.Collections.singletonList;