This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios, { AxiosError } from 'axios'; | |
import fs from 'fs'; | |
import formData from 'form-data'; | |
const imageUploaderKeyEnvVar = process.env['IMG_UPLOADER_KEY']; | |
export class ImageUploader { | |
static async upload(imagePath: string): Promise<string> { | |
const form = new formData(); | |
const image = fs.readFileSync(imagePath, { encoding: 'base64' }).toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assert_valid_value(value) | |
unless value.blank? || mapping.has_key?(value) || mapping.has_value?(value) | |
raise ArgumentError, "'#{value}' is not a valid #{name}" | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("dotenv").config(); | |
const redis = require("redis"); | |
const { REDIS_URL } = process.env; | |
(async () => { | |
// connect to Redis | |
let redisClient; | |
if (REDIS_URL) { | |
redisClient = redis.createClient(REDIS_URL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Sequelize = require("sequelize"); | |
module.exports = new Sequelize({ | |
database: "test", | |
username: "root", | |
password: "mysecretpassword", | |
dialect: "postgres", | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"regexp" | |
"github.com/disintegration/imaging" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "exercise.hpp" | |
#define endl '\n' | |
using namespace std; | |
int print_usage() | |
{ | |
cout << "./create-exercise " << endl; | |
cout << "./create-exercise [exercise_number]'" << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
int n; | |
cin >> n; | |
int answer = n; /// assume we used all of coin1 | |
for (int c4 = 0; c4 <= n / 4; c4++) { // try to take c4 of coin4 | |
for (int c3 = 0; c3 <= (n - 4 * c4) / 3; c3++) { // try to take c3 of coin3 | |
int c1 = n - (4 * c4 + 3 * c3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main () { | |
long long n, m; | |
scanf("%lld %lld", &n, &m); | |
const long long MOD = 17e7; // same as 17x10^7 | |
long long ans = m; | |
// or ans = 1 and for(int i = 0; i < n; i++) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_all_posts_content() { | |
let my_txt = ""; | |
const posts = document.querySelectorAll("._5pbx.userContent"); | |
for (const post of posts) { | |
my_txt += post.innerText + "\n-------------------\n" | |
} | |
return my_txt | |
} | |
function click_all_see_more() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt update | |
sudo apt install software-properties-common apt-transport-https wget | |
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | |
sudo apt update | |
sudo apt install code |
NewerOlder