Skip to content

Instantly share code, notes, and snippets.

View dac09's full-sized avatar

Daniel Choudhury dac09

  • Bangkok
  • 17:06 (UTC +07:00)
View GitHub Profile
@bbshih
bbshih / momentMock.js
Last active February 22, 2023 18:27 — forked from lededje/gist:44aeddf1dc2a5e6064e3b29dc35a7a2d
Jest Mocking Moment to same time zone for tests
// To mock globally in all your tests, add to setupTestFrameworkScriptFile in config:
// https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string
jest.mock('moment', () => {
const moment = require.requireActual('moment-timezone');
moment.tz.setDefault('America/Los_Angeles'); // Whatever timezone you want
return moment;
});
@ziluvatar
ziluvatar / token-generator.js
Last active November 13, 2025 08:02
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@Ashung
Ashung / sketch_diff.sh
Last active January 21, 2020 12:26
Diff Sketch file with Kaleidoscope.
#!/usr/bin/env bash
sketchtool=/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool
#echo $(python --version)
function extractSketchFile () {
sketchFile=$1
folder=${sketchFile%.sketch}
@budidino
budidino / compressVideo.swift
Created January 24, 2017 08:55
compress and optionally mute video in Swift 2
func compressVideo(inputURL: NSURL, outputURL: NSURL, bitRate: Int, muteSound: Bool, onDone: () -> ()) {
let videoAsset = AVURLAsset(URL: inputURL, options: nil)
let videoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo)[0]
let videoSize = videoTrack.naturalSize
let videoWriterCompressionSettings = [
AVVideoAverageBitRateKey: bitRate
]
let videoWriterSettings:[String : AnyObject] = [
AVVideoCodecKey : AVVideoCodecH264,
@moreJs
moreJs / ngrxintro.md
Created November 28, 2016 06:00 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

#Comprehensive Introduction to @ngrx/store By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@ctranxuan
ctranxuan / Configurations.md
Last active November 21, 2017 23:32
SpringBoot things

How to load @ConfigurationProperties manually from a Yaml configuration file

Let's say we have the following yaml configuration file:

foo:
    apis:
      -
        name: Happy Api
 path: /happyApi.json?v=bar
@DaniSancas
DaniSancas / neo4j_cypher_cheatsheet.md
Created June 14, 2016 23:52
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)
@melv-n
melv-n / CustomComponent-test.js
Last active November 9, 2021 09:32
Testing React-Intl components with Enzyme's mount() and shallow() methods. This is a helper function which wraps the `intl` context around your component tests in an easy and efficient way.
import { mountWithIntl } from 'helpers/intl-enzyme-test-helper.js';
const wrapper = mountWithIntl(
<CustomComponent />
);
expect(wrapper.state('foo')).to.equal('bar'); // OK
expect(wrapper.text()).to.equal('Hello World!'); // OK
'use strict'
// const yargs = require('yargs')
const express = require('express')
const request = require('request')
const uuid = require('node-uuid')
const querystring = require('querystring')
const opener = require('opener')
let argv = require('yargs')
@ShinJJang
ShinJJang / detect.java
Last active December 5, 2021 16:00
Test for detect virtual device in android
// This is not perfect
private boolean isVirtualDeivce() {
String msg = "BOARD = " + Build.BOARD +
"\nBOOOTLOADER = " + Build.BOOTLOADER +
"\nBRAND = " + Build.BRAND +
"\nDEVICE = " + Build.DEVICE +
"\nDISPLAY = " + Build.DISPLAY +
"\nFINGERPRINT = " + Build.FINGERPRINT +
"\nHARDWARE = " + Build.HARDWARE +
"\nHOST = " + Build.HOST +