Skip to content

Instantly share code, notes, and snippets.

View levlaz's full-sized avatar

Lev Lazinskiy levlaz

View GitHub Profile
@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)
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)
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]}
@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:
@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]")
/**
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.pl
Created February 5, 2018 19:27
LD Perl Example
#!/usr/bin/perl
use strict;
use warnings;
sub ShowFeature {
my ($key, $user) = @_;
ld_eval($key, $user);
};
@levlaz
levlaz / cgitrc
Last active January 2, 2018 21:51
cgit Debian
#cgit config
#===========
#see cgitrc(5) for details
#=========================
css=/cgit.css
logo=/cgit.png
virtual-root=/
@levlaz
levlaz / db.py
Created December 22, 2017 02:01
Python + Sqlite DB Migration Example Code
def connect_db():
"""Connects to Database."""
rv = sqlite3.connect(
app.config['DATABASE'],
detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
rv.row_factory = sqlite3.Row
return rv
def get_db():
@levlaz
levlaz / font-awesome-and-laravel.md
Last active March 4, 2025 23:54
How To Use Font Awesome With Laravel

For some reason there is a whole thread on this seemingly simple tasks. In a bootstrapped Laravel 5.4 instance the following worked for me.

Install Font Awesome with NPM

npm install font-awesome

Import font-awesome in your app.scss file