Skip to content

Instantly share code, notes, and snippets.

@nazieb
nazieb / CustomXenditHttpClient.php
Last active January 18, 2021 15:20
Send Custom Header using Xendit PHP Library
<?php
class CustomXenditHttpClient implements \Xendit\HttpClientInterface
{
public function request($method, $uri, array $options = []) {
$client = new \GuzzleHttp\Client([
'headers' => ['X-API-VERSION' => '2019-02-04'],
'base_uri' => \Xendit\Xendit::$apiBase,
]);
return $client->request($method, $uri, $options);
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
const awsServerlessExpress = require("aws-serverless-express");
const app = require("./app");
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => {
awsServerlessExpress.proxy(server, event, context);
}
const app = require("./app");
app.listen(process.env.PORT, () => {
console.log("App is running...");
});
@nazieb
nazieb / app.js
Last active February 2, 2019 16:34
const express = require("express");
const app = express();
app.get("/hello", (req, res) => {
res.json({
message: "Hello, World",
});
});
app.post("/ping", (req, res) => {
const express = require("express");
const app = express();
app.get("/hello", (req, res) => {
res.json({
message: "Hello, World",
});
});
app.post("/ping", (req, res) => {
@nazieb
nazieb / app.js
Created February 2, 2019 15:17
AWS Lambda-Express example
const express = require("express");
const app = express();
app.get("/hello", (req, res) => {
res.json({
message: "Hello, World",
});
});
app.post("/ping", (req, res) => {
const express = require('express');
const app = express();
const puppeteer = require('puppeteer');
const ua = require("useragent");
function isBot(userAgent) {
const agent = ua.is(userAgent);
return !agent.webkit && !agent.opera && !agent.ie &&
!agent.chrome && !agent.safari && !agent.mobile_safari &&
!agent.firefox && !agent.mozilla && !agent.android;
@nazieb
nazieb / shortener.go
Created March 3, 2017 08:03
ID shortener in Golang
package shortener
import (
"strings"
)
var shortenerDict = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789` // you can customize this, just make sure there's no duplicate chars
var shortenerBase = len(shortenerDict)
func ShortenID(ID int64) string {
@nazieb
nazieb / Dockerfile
Created July 28, 2016 13:08
Docker for API Blueprint builder
FROM debian:jessie
RUN apt-get update \
&& apt-get install -y git nodejs php5-common php5-cli --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g aglio
RUN git clone --recursive git://github.com/apiaryio/drafter.git \
&& cd drafter \