Skip to content

Instantly share code, notes, and snippets.

@remorses
remorses / client.html
Created September 17, 2017 17:57 — forked from diorahman/client.html
Ajax, call jQuery POST to node.js expressjs
<html>
<head>
<title>jsonp test</title>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(function(){
$('#select_link').click(function(e){
e.preventDefault();
console.log('select_link clicked');
@remorses
remorses / deploy_image.sh
Last active February 12, 2019 14:34
Docker deploy with version tag
set -ex
##################################################
REGISTRY="myregistry.com:5000" # for docker hub just put your username
IMAGE=`basename $PWD` # image name
##################################################
set -ex
cd `dirname ${BASH_SOURCE[0]}`
test -f ./VERSION || (echo "file VERSION containing current version is needed" && exit 1)
git pull
rm -rf *.egg-info
rm -rf dist
rm -rf build
@remorses
remorses / multiway_trees_bfs.hs
Created May 28, 2019 19:19
breadth first search (bfs) for multiway trees implemented in haskell
data Tree a = Node a [Tree a]
traverseBF :: Tree a -> Tree a
traverseBF tree = tbf tree
where
tbf (Node x []) = Node x []
tbf (Node x xs) = Node x (map tbf $ xs)
@remorses
remorses / dicts_set.py
Created July 12, 2019 11:35
set of dictionaries in python
l = [
{
'a': 1,
'b': 1,
},
{
'a': 2,
'b': 1,
},
{
@remorses
remorses / main.md
Created January 25, 2020 14:48
react-extra-hooks-article

I have always used Apollo to make graphql requests inside of react, usually doing something like this

import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';

const GET_GREETING = gql`
  query getGreeting($language: String!) {
    greeting(language: $language) {
      message
@remorses
remorses / main.ts
Created February 26, 2020 14:44
Cloud storage uplaod file and get url
import admin from 'firebase-admin'
const file = admin
.storage()
.bucket('')
.file('name.txt')
await file.save('dsfgsdf', {
gzip: true,
public: true,
contentType: 'image',
})
@remorses
remorses / main.ts
Created February 26, 2020 15:21
Download a file with node-fetch
const buffer = await fetch(url).then((r) => r.buffer())
const content = buffer.toString('utf8')
// then pass this where you like
@remorses
remorses / main.graphql
Created March 7, 2020 15:39
Get graphql enum values
query enumValuesOfMetaInformationTags {
__type(name: "META_INFORMATION_TAGS") {
name
enumValues {
name
}
}
}
import path from "path";
import fs from "fs";
import { getPackages } from "@monorepo-utils/package-utils";
const sourceDir = "src";
getPackages(__dirname).map(x => {
let types = getTypesFile({
sourceDir: path.resolve(x.location, sourceDir)
});