Skip to content

Instantly share code, notes, and snippets.

@it-one-mm
it-one-mm / worker.js
Created June 10, 2021 00:53 — forked from gbuszmicz/worker.js
Heroku worker process
const amqp = require('amqp-connection-manager')
const AMQP_URL = process.env.CLOUDAMQP_URL || 'amqp://localhost';
if (!AMQP_URL) process.exit(1)
const WORKER_QUEUE = 'worker-queue'
// Create a new connection manager from AMQP
var connection = amqp.connect([AMQP_URL])
@it-one-mm
it-one-mm / clock.js
Created June 10, 2021 00:53 — forked from gbuszmicz/clock.js
Heroku clock.js process
const CronJob = require('cron').CronJob
const amqp = require('amqp-connection-manager')
const AMQP_URL = process.env.CLOUDAMQP_URL || 'amqp://localhost';
if (!AMQP_URL) process.exit(1)
const WORKER_QUEUE = 'worker-queue' // To consume from worker process
const CLOCK_QUEUE = 'clock-queue' // To consume from clock process
const JOBS = [{ // You could store these jobs in a database
name: "Cron process 1",
@it-one-mm
it-one-mm / how-to-copy-aws-rds-to-local.md
Created December 24, 2020 09:47 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@it-one-mm
it-one-mm / Public_Time_Servers.md
Created October 1, 2020 14:10 — forked from mutin-sa/Top_Public_Time_Servers.md
List of Top Public Time Servers

Google Public NTP [AS15169]:

time.google.com

time1.google.com

time2.google.com

time3.google.com

@it-one-mm
it-one-mm / settrade.py
Created September 29, 2020 09:52 — forked from windows98SE/settrade.py
THAILAND SETTRADE for scrollphathd
import requests
import time
import scrollphathd
from scrollphathd.fonts import font3x5
class SETTRADE:
def __init__(self):
@it-one-mm
it-one-mm / ad_helper.dart
Last active June 26, 2021 18:54
Flutter Movie App Snippet
import 'dart:io';
class AdHelper {
static String get bannerAdUnitId => Platform.isAndroid
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716';
static String get interstitialAdUnitId => Platform.isAndroid
? "ca-app-pub-3940256099942544/1033173712"
@it-one-mm
it-one-mm / UploadAnt.tsx
Created August 21, 2020 06:07
File Upload using Ant with s3
import React, { useState } from 'react';
import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import axios from 'axios';
import { generateDateForFileName } from '../utils/helpers';
const nodeServerEndpoint = 'http://localhost:4000/api/v1/aws/sign-s3';
const phpServerEndpoint = 'http://localhost:9000/api/v1/signed-url-put-object';
const UploadAnt = () => {
@it-one-mm
it-one-mm / change_route.dart
Last active September 23, 2020 09:12
Change Route like Viu using Drawer
void _changeRoute(BuildContext context, String newRouteName) {
print('newRouteName: $newRouteName');
// Close drawer
Navigator.pop(context);
// Check current screen status
bool currentRouteIsHome = false;
bool currentRouteIsNewRoute = false;
Navigator.popUntil(context, (currentRoute) {
@it-one-mm
it-one-mm / async-await-exercise.js
Created July 7, 2020 10:03
Async Await Course in React Native from IT ONE MM
getCustomer(1, (customer) => {
console.log('Customer: ', customer);
if (customer.isGold) {
getTopMovies((movies) => {
console.log('Top movies: ', movies);
sendEmail(customer.email, movies, () => {
console.log('Email sent...')
});
});
@it-one-mm
it-one-mm / createDataContext.tsx
Created June 23, 2020 17:06
Create Global Context
import React, { Dispatch, useReducer, createContext, ReactNode } from 'react';
type Props = {
children: ReactNode;
};
function createDataContext<S, A>(
reducer: (state: S, action: A) => S,
initialState: S
) {