Skip to content

Instantly share code, notes, and snippets.

View Igosuki's full-sized avatar

Guillaume Balaine Igosuki

View GitHub Profile
@Igosuki
Igosuki / database.js
Created August 19, 2015 15:30
Example ECMA6 App
"use strict";
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
@Igosuki
Igosuki / README.md
Created July 29, 2016 10:29
Create a DC/OS Single Master Cluster on AWS

Usage :

  chmod u+x ./zen.sh
  ./zen.sh my-dcos-stack
@Igosuki
Igosuki / core.cljs
Created August 31, 2016 09:11
Add the following to relevant files to get react-select with reagent
(ns core
(:require [cljsjs.react-select]))
(defn my-select []
[:> js/Select {:name "Select"
:value "Tom"
:on-change #(println "Change ! : " %)
:filter-options false
:options [{:value "Tom" :label "Tommy"}
{:value "Tom2" :label "Tommy2"}
@Igosuki
Igosuki / db.clj
Created May 18, 2017 14:16
Initializing a database and migrating with ragtime
(ns db
(:require [[ragtime.jdbc :as ragjdbc]
[clojure.tools.logging :as log]
[clojure.java.jdbc :as jdbc]
[ragtime.repl :as ragrepl]])
(defn ragtime-config [database]
{:datastore (ragtime.jdbc/sql-database database)
:migrations (ragtime.jdbc/load-resources "migrations")})
@Igosuki
Igosuki / LateReduceExample.scala
Last active August 16, 2017 11:06
Buggy reduce in scio
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility
import com.fasterxml.jackson.annotation.PropertyAccessor
import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper, SerializationFeature}
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import com.spotify.scio.ContextAndArgs
import com.spotify.scio.values.WindowOptions
import org.apache.beam.sdk.io.TextIO.CompressionType
import org.apache.beam.sdk.transforms.windowing.AfterProcessingTime
import org.apache.beam.sdk.values.WindowingStrategy.AccumulationMode
@Igosuki
Igosuki / ws.scala
Last active December 20, 2021 15:46
http4s fs2 websocket
abstract class UserWSEndpoint[F[+ _]: Timer: Concurrent: ContextShift](
broadcastTopic: Topic[F, PushNotification])(implicit F: ConcurrentEffect[F])
extends Http4sDsl[F]
with Loggable {
def broadcast(e: PushNotification) = broadcastTopic.publish1(e)
def toText[A: Encoder](a: A)(implicit e: Encoder[A], wse: Encoder[WSMessage]) =
Text(wse(WSMessage("", "", e(a).some, "", "".some)).asString.get)
@Igosuki
Igosuki / Endpoint.scala
Created May 7, 2019 10:11
Circe - Magnolia problem example
import io.circe.magnolia.derivation.encoder.auto._
import org.http4s.rho._
import cats.implicits._
import cats.effect._
import com.us.repos._
class AppsEndpoint[F[+ _]: Effect](appsDao: AppsRepo[F], swaggerSyntax: SwaggerSyntax[F]) extends RhoRoutes[F] {
import swaggerSyntax._
// If appsDao.list is F[Seq[App]] then the jsonEncoder outputs '[...]'
@Igosuki
Igosuki / mywidget.php
Created May 10, 2019 16:35
Wordpress widget
<?php
global $wpdb;
$current_user_id = get_current_user_id();
$search_history = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}relevanssi_log WHERE user_id = {$current_user_id} ORDER BY time DESC");
?>
@Igosuki
Igosuki / index.js
Created November 21, 2019 10:18
Reading NodeJS JSON encoded buffers in Python.
const j = '{"type":"Buffer","data":[93,204,151,170,0,0,194,155,10,119,139,1,10,13,41,43]}'
const buffer = Buffer.from(JSON.parse(j).data)
console.log(typeof buffer);
console.log('str' + buffer.toString('hex'))
@Igosuki
Igosuki / index.js
Last active November 21, 2019 10:20
Reading NodeJS JSON encoded buffers in Python.
const j = '{"type":"Buffer","data":[93,204,151,170,0,0,194,155,10,119,139,1,10,13,41,43]}'
const buffer = Buffer.from(JSON.parse(j).data)
console.log(JSON.stringify(buffer)); // verify that a buffer is stringified as the string above by default
console.log('buffer string value : ' + buffer.toString('hex')) // concat with str