Skip to content

Instantly share code, notes, and snippets.

@xasima
xasima / calculator-api-swagger-generator.js
Last active April 22, 2021 13:47
Calculator-react-sample
// calculator-api-swagger/generator.js
var fs = require('fs');
var CodeGen = require('swagger-js-codegen').CodeGen;
var file = 'api/swagger/swagger.json';
var swagger = JSON.parse(fs.readFileSync(file, 'UTF-8'));
var reactjsSourceCode = CodeGen.getReactCode({ className: 'Test', swagger: swagger });
console.log(reactjsSourceCode);
//var tsSourceCode = CodeGen.getTypescriptCode({ className: 'Test', swagger: swagger, imports: ['../../typings/tsd.d.ts'] });
@xasima
xasima / greeter.js
Last active April 3, 2018 08:00
Sample code for Express
function greeter(person) {
return "Hello, " + person;
}
var user = "Jane";
var eventPlaceId = "greeter";
alert('hello world in JS!');
document.getElementById(eventPlaceId).innerHTML = greeter(user);
// OSX
open /Applications/Google\ Chrome.app --args --disable-web-security --user-data-dir
// Linux
chromium-browser --disable-web-security --user-data-dir
// Windows
// (Needs to find where is Chrome Link: may just right click on Chrome icon and choose its properties and path)
// later
cd /D C:/UserData/Microsoft/Windows/...
@xasima
xasima / RestFinchServer.scala
Created July 17, 2016 21:25
circe in finch question
import com.twitter.app.Flag
import com.twitter.finagle.http.{Request, Response}
import com.twitter.finagle.{Http, ListeningServer, Service}
import com.twitter.server.TwitterServer
import com.twitter.util.Await
import io.circe.{Encoder, Json}
import io.finch._
import io.finch.circe._
@xasima
xasima / model.scala
Last active August 29, 2015 14:21
Finch usage to transfer custom headers
// Let change finch example to specify custom http-headers (let call them CTPPHeader) per models
object model {
trait ToJsonWithHeaders {
def toJson: Json
// provide specific headers per model file
def getTemplate :String
}
@xasima
xasima / ETag.scala
Created May 2, 2015 19:56
Thrift, json, and scrooge scala to test scrooge(thrift) - argounaut(json) bijection
/**
* Generated by Scrooge
* version: 3.14.1
* rev: a996c1128a032845c508102d62e65fc0aa7a5f41
* built at: 20140501-114707
*/
package com.xxx.services
import com.twitter.scrooge.{
TFieldBlob, ThriftException, ThriftStruct, ThriftStructCodec3, ThriftStructFieldInfo, ThriftUtil}
@xasima
xasima / gist:56e5fe7c841199475f5c
Last active August 29, 2015 14:20
finagle-finch with argonaut-json implicit conversion
// These are snippets based on the recent finch demo package.
// Some modification are added to eliminate usage of ToJson trait,
// but use argonaut Json via implicits instead.
// The purpose of ToJson trait removal is to bypass compilers errors on
// Service[AuthRequest, Seq[argonaut.Json]] to Service[AuthRequest, Json]]
// conversion.
// See current compilers errors at the bottom of the gist
@xasima
xasima / aurora-configuration-issue.md
Last active August 29, 2015 14:15
aurora configuration issue

Mesos Master and Slave status

> lsb_release -a | grep Description
Description:	Ubuntu 12.04.4 LTS

> sudo lsof -i :2181 | grep '(LISTEN)'
java      29720 zookeeper   27u  IPv4 236483534      0t0  TCP *:2181 (LISTEN)

> mesos-master --version
@xasima
xasima / build.gradle
Created January 19, 2015 21:27
Gradle file with multidex, scala, android-annotations
// ----------- Build script configuration
buildscript {
repositories {
mavenCentral()
maven { url 'http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot' }
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
maven { url 'https://maven.fabric.io/public' }
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
@xasima
xasima / gist:7825313
Last active December 30, 2015 11:49
The log of testing the `grunt server` command when using yoman's generator-closure
weblab@devbox:~/projects$ grunt --version
grunt-cli v0.1.11
weblab@devbox:~/projects$ yo --version
1.0.4
weblab@devbox:~/projects/closure-test$ node --version
v0.8.26
weblab@devbox:~/projects/closure-test$ npm --version