Skip to content

Instantly share code, notes, and snippets.

@yazinsai
yazinsai / Android-Emulator-on-AWS-EC2.md
Last active August 9, 2024 15:26 — forked from atyachin/Android-Emulator-on-AWS-EC2.txt
Installing and running Android Emulator on Amazon AWS EC2 (Ubuntu 16.04 / m5.xlarge)

Getting the Android Emulator running on EC2 📱

# @ your EC2 instance
sudo apt update
sudo apt install openjdk-8-jre unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d android-sdk
sudo mv android-sdk /opt/
export ANDROID_SDK_ROOT=/opt/android-sdk
@yazinsai
yazinsai / ImportJSON.gs
Created April 26, 2016 13:38
Get data from any API straight into your Google Sheets, effortlessly!
/*====================================================================================================================================*
ImportJSON by Trevor Lohrbeer (@FastFedora)
====================================================================================================================================
Version: 1.2.1
Project Page: http://blog.fastfedora.com/projects/import-json
Copyright: (c) 2012-2013 by Trevor Lohrbeer
License: GNU General Public License, version 3 (GPL-3.0)
http://www.opensource.org/licenses/gpl-3.0.html
------------------------------------------------------------------------------------------------------------------------------------
A library for importing JSON feeds into Google spreadsheets. Functions include:
function StreamedText() {
const [text, setText] = React.useState("");
React.useEffect(() => { getStream() }, []);
function getStream() {
// Fetch the stream
const stream = await fetch('/api/answer', { method: 'POST', body: JSON.stringify({ query } }) })
const data = stream.body;
if (!data) return;
@yazinsai
yazinsai / stream.ts
Last active May 16, 2023 07:40
Streams an OpenAI response, compatible with Next.js
/**
* Usage:
*
* export const config = {
* runtime: "edge",
* };
*
* const stream = await streamFromResponse(await openai.complete({
* model: 'gpt-3.5-turbo',
* prompt: 'this is a test',
const flattenObjectToMongoDbFormat = (obj, ancestors = []) => {
/**
* When you want to update a MongoDB document, without overriding
* nested fields that are not specified, you need to specify the
* nested fields in the format:
* `$set: { "parent.nested.key": "value" }`
*
* This method takes a nested object (usually from an incoming API
* request) and converts it to the nested format.
*/
export const flattenObjectToMongoDbFormat = (obj: any, parent: String = ''): any => {
/**
* When you want to update a MongoDB document, without overriding
* nested fields that are not specified, you need to specify the
* nested fields in the format:
* `$set: { "parent.nested.key": "value" }`
*
* This method takes a nested object (usually from an incoming API
* request) and converts it to the nested format.
*/
@yazinsai
yazinsai / bash-cheatsheet.sh
Created April 6, 2021 07:35 — forked from kannaiah/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@yazinsai
yazinsai / convertkit.js
Created November 11, 2020 10:50
A simple script to register a user to ConvertKit using only Javascript
/* Submit an email address to ConvertKit using only Javascript */
function submitForm(email) {
fetch('https://app.convertkit.com/forms/XXXXXX/subscriptions', {
// replace XXXXXX above with your form ID (e.g. 1231234)
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: `email_address=${email}`
}).then((response) => {
const elemsIn = (tag, parent) => Array.from(parent.getElementsByTagName(tag));
const speedUp = (v) => v.playbackRate = 2;
const videos = elemsIn('video', document);
const iframes = elemsIn('iframe', document);
videos.forEach(speedUp);
iframes.forEach((f) => elemsIn('video', f.contentWindow.document).forEach(speedUp));
@yazinsai
yazinsai / parse-ayat.rb
Created July 5, 2020 09:45
A simple Ruby script to parse text from the Quran into text without diacritics
#!/usr/bin/env ruby
# 1. Copy the raw text from https://www.corequran.com/
# 2. Run "ruby parse.rb"
# 3. Paste the copied text
# 4. Press "Ctrl + D" to see the output
def parse(str)
str
.split("\n")