Skip to content

Instantly share code, notes, and snippets.

import csv
import redis
import sys
from itertools import zip_longest
r = redis.Redis(host='localhost', port=6379)
csvwriter = csv.writer(sys.stdout)
def batcher(iterable, n):
@forkfork
forkfork / simplecode.js
Created March 14, 2022 13:10
simplequeue
const Redis = require("ioredis");
const { v4: uuidv4 } = require('uuid');
const redis = new Redis();
const LIFETIME_MS = 1000;
let status = 'running';
const processId = uuidv4();
const sleep = (milliseconds) => {

Full Stack Javascript Developer (node.js, react)

Here at Luxury Escapes, our mission is to delight our customers with incredible deals for the world's best holidays.

You'll be joining one of our several small, cross-functional teams. You'll be working across the full stack, though we're also open to someone with more of a backend or frontend focus.

We're small-a agile, so we have daily stand ups, pretty autonomous teams, and devs deploy to prod many times every day. We have a flat, collaborative structure both within and between teams.

Relevant skills:

@forkfork
forkfork / reorder_content.md
Created July 24, 2018 04:21
reordering content by country

What we have now:

  • The content page in admin is used to reorder all scheduled offers (regardless of which scheduled country)
test-le-svc-offer-syd::DATABASE=> \d offer_brand
                             Table "public.offer_brand"
         Column         |         Type          | Collation | Nullable |  Default   
------------------------+-----------------------+-----------+----------+------------
 fk_offer_salesforce_id | character varying(18) |           | not null | 
@forkfork
forkfork / lux_coding_test.md
Last active March 12, 2018 06:06
Lux Coding Test Node.js

Lux Group Coding Test

We would like you to create a simple Node.js express server which has a single route, /api/search?q=thailand (the thailand part is a variable).

The new route will request packages from "https://api.luxgroup.com/api/public-offers/", and will return a filtered view of content - with the same structure, but filtering to just show the packages based on text-searching the .result[].name and .result[].location fields for the content in the "q" query param.

Please include:

  • a package.json (so we can get deps and run the project)
  • suitable test coverage
@forkfork
forkfork / gist:6846a0aaf25a94f1db9c7d666aec8fca
Last active February 13, 2018 02:32
Mobile Config Phase 2
Currently:
- S3 bucket proxy_pass
Plan A:
- Serve mobile config route from svc-discovery
- Continue to store 'main' state file in S3
- Add an 'index' state file which looks something like:
@forkfork
forkfork / ioredis_example.js
Last active April 13, 2021 17:41
Example of using Redis Streams with Javascript/ioredis
var Redis = require('ioredis');
var redis = new Redis({
host: "nodesydney.wiftycloud.com",
password: "7884b8baaa49fbcb48f17ad2a146"
});
async function main() {
// write an event to stream 'events', setting 'key1' to 'value1'
await redis.sendCommand(
@forkfork
forkfork / Getting_Started.md
Last active December 16, 2017 12:19
Getting Started - Event Streaming in 10 minutes

Getting Started - Event Streaming in 10 minutes

Wiftycloud instances allow you to manage a stream of events. Events might be customer behaviour such as registration, login, or purchasing.

Concepts

Events are has the follow attributes:

  • An ID, a timestamp with deduplication - for example: 1511695734461-0. This is auto-generated by the server.
@forkfork
forkfork / prelimstreamdocs.md
Last active May 27, 2020 17:22
Redis Streams

XADD streamname [MAXLEN items] * field value [field value ...]

Adds a set of fields with values to the specified stream. If MAXLEN items are exceeded, items are removed from the beginning of the stream to bring the length down to MAXLEN. The "*" field is to autogenerate an item ID, but can be overriden.

Return value

Simple string reply: epoch time (in milliseconds) followed by a .N (for differentiating multiple events on the same millisecond)

local co
local fetch = function(url)
local promise = js.global:fetch(url)
promise["then"](promise, function(_, res)
local jsonPromise = res:json()
jsonPromise["then"](jsonPromise, function(_, json)
co(json)
end)
end)