Skip to content

Instantly share code, notes, and snippets.

View J3698's full-sized avatar
๐Ÿ›
Inch Worm

Anti J3698

๐Ÿ›
Inch Worm
  • Working
  • Working
View GitHub Profile
@J3698
J3698 / get_batch_style_transfer_loss.py
Created January 28, 2021 01:55
get batch style transfer loss
def get_batch_style_transfer_loss(encoder, decoder, style_image, content_image):
style_features = encoder(style_image)
content_features = encoder(content_image)
stylized_image, stylized_features = create_stylized_image(decoder, content_features, style_features)
features_of_stylized = encoder(stylized_image)
style_loss = compute_style_loss(features_of_stylized, style_features)
content_loss = compute_content_loss(features_of_stylized, stylized_features)
@J3698
J3698 / create_stylized_image.py
Created January 28, 2021 01:28
create stylized image
def create_stylized_image(decoder, content_features, style_features):
stylized_content_features = adain(content_features[-1], style_features[-1])
stylized_image = decoder(stylized_content_features)
return stylized_image, stylized_content_features
/*
* Create a shortening and return the shorturl if successful. Returns null if
* the shorturl already exists and is not the requested shortening, or if the
* longurl already has a random shortening and this shortening is also random.
*
* May throw other db errors.
*/
const addShortening = async (shortUrl, longUrl, isRandom) => {
let addShorteningQuery = 'INSERT INTO shortenings (shorturl, longurl, israndom) VALUES ($1, $2, $3)';
@J3698
J3698 / queries-setup.js
Created May 24, 2020 16:45
Setup pg in node
const assert = require('assert');
const Pool = require('pg').Pool;
const pool = new Pool({
user: 'me',
host: 'localhost',
database: 'urlmem',
password: 'password',
port: 5432,
});
@J3698
J3698 / manifest.json
Created April 23, 2020 06:21
Manifest for ISpokeToMyAdvisor
{
"name": "ISpokeToMyAdvisor",
"version": "1.0",
"description": "Hide the \"Have you spoken to your advisor?\" message on SIO.",
"permissions": ["activeTab"],
"content_scripts": [
{
"matches": ["https://s3.andrew.cmu.edu/*"],
"js": ["deleter.js"]
}
@J3698
J3698 / deleter.js
Last active April 23, 2020 06:24
Deletes the SIO popup
function deletePopup() {
// check if the backdrop exists
var dialogBox = document.getElementsByClassName("gwt-DialogBox");
if (dialogBox.length != 0) {
dialogBox = dialogBox[0];
// if backdrop exists, check if message matches "have you spoken..."
caption = dialogBox.getElementsByClassName("Caption")[0].innerHTML;
if (caption == "Have You Spoken to Your Advisor?") {
// remove!!!!!!!!
dialogBox.parentNode.removeChild(dialogBox);
#.env
GENERATE_SOURCEMAP=false
// GET route for custom URLs
app.get('/custom', (req, res) => {
// sanitize input
if (typeof (req.query.longUrl) !== "string" ||
typeof (req.query.customUrl) !== "string") {
res.send({"shortened": null});
return;
}
let longUrl = qualify(req.query.longUrl);
renderOutputs() {
return (
<TransitionGroup>
{this.state.shortenedUrls.map(UrlPair =>
<CSSTransition
key={UrlPair.id}
timeout={300}
classNames='latestOut'
>
<UrlOutput longUrl={UrlPair.longUrl}
@J3698
J3698 / vim8_on_andrew
Last active March 22, 2020 20:45
Install vim with autocomplete
#!/usr/bin/env bash
# clone vim and vundle
cd ~
git clone https://github.com/vim/vim.git
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# build vim
cd vim
git checkout a21df1db3ca619afdcb47931af042508a6bbc8e5