Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / linux-setup.sh
Last active May 1, 2024 12:48
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@manniru
manniru / app.js
Created August 30, 2019 22:20 — forked from bingeboy/app.js
Upload and display image with NodeJS and Express.
/*
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, common = require('./routes/common')
, fs = require('fs')
, http = require('http')
, util = require('util')
const epochToJsDate = (ts) => {
if (ts.length === 10) return new Date(ts*1000);
else if (ts.length === 13) return new Date(parseInt(ts))
else return ts;
}
// payment.date = epochToJsDate(1500026871)
@manniru
manniru / number-pad-zero.js
Created August 29, 2019 19:55 — forked from endel/number-pad-zero.js
Simplest way for leading zero padding in JavaScript
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
}
(1).pad(3) // => "001"
(10).pad(3) // => "010"
(100).pad(3) // => "100"
.site-logo {
display: inline-block;
height: 39px;
}
/* line 6, ../sass/partials/_block.scss */
.site-logo img {
margin:0 auto 0 auto;
padding:0;
width:300px;
}
SETUP:
wget -O drive https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg
mv drive /usr/sbin/drive
chmod 755 /usr/sbin/drive
Now, simply run drive to start the authentication process. You'll get a link like this to paste and browse to in to your web browser:
@manniru
manniru / copyFirestoreDB.js
Created September 14, 2019 20:28 — forked from brunobraga95/copyFirestoreDB.js
Copy firestore database
const firebase = require('firebase-admin');
var serviceAccountSource = require("./source.json"); // source DB key
var serviceAccountDestination = require("./destination.json"); // destiny DB key
const sourceAdmin = firebase.initializeApp({
credential: firebase.credential.cert(serviceAccountSource)
});
const destinyAdmin = firebase.initializeApp({
$pic = file_create_url('public://images/1417218384.jpg');
$row['picture'] = [
'data' => [
'#type' => 'html_tag',
'#tag' => 'img',
'#attributes' => ['src' => $pic, 'width' => '70'],
],
];
const cors = require('cors')({origin: true});
exports.remita_rrrstatus = functions.https.onRequest(
async (req, res) => {
res.set('Access-Control-Allow-Origin', "*")
res.set('Access-Control-Allow-Methods', 'GET, POST')
cors(req, res, async () => {
try {
import React, { Fragment, useState, useEffect } from 'react';
import axios from 'axios';
function App() {
const [data, setData] = useState({ hits: [] });
const [query, setQuery] = useState('redux');
const [url, setUrl] = useState(
'https://hn.algolia.com/api/v1/search?query=redux',
);
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {