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 csv | |
def toMarkdown(item): | |
newTemp = "---"+"\n"+"layout: sculpture"+"\n"+"pageId: "+item[0]+"\n"+"uid: "+item[1]+"\n" | |
newTemp += "title: "+item[2]+"\n"+"location: "+item[3]+"\n"+"completionDate: "+item[4]+"\n" | |
newTemp += "description: "+item[5]+"\n"+"imageId: "+item[6]+"\n" | |
newTemp += "---"+"\n" | |
return newTemp | |
with open('file.csv', 'rb') as f: |
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
let cache; | |
const TTL = 1500; | |
const callApi = () => { | |
return new Promise((res, rej) => res('1234')) | |
} | |
async function getData() { | |
if (cache) return cache; | |
try { | |
const newProm = await callApi(); | |
console.log('get new result', newProm); |
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
async function success() { | |
return new Promise((res, rej) => res('Resolved')); | |
} | |
async function error() { | |
return new Promise((res, rej) => rej('Rejected')); | |
} | |
// then, catch syntax | |
function allSettled(promises) { | |
const allPromises = promises.map((p) => { |
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
//from this post http://bucketpress.com/next-and-previous-post-link-in-same-custom-taxonomy | |
// get_posts in same custom taxonomy | |
$postlist_args = array( | |
'posts_per_page' => -1, | |
'orderby' => 'menu_order title', | |
'order' => 'ASC', | |
'post_type' => 'your_custom_post_type', | |
'your_custom_taxonomy' => 'your_custom_taxonomy_term' | |
); | |
$postlist = get_posts( $postlist_args ); |
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 fs = require('fs'); | |
const path = require('path'); | |
const bytes_100 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mauris augue, vulputate sit amet dolor.\n'; | |
const bytes_400 = bytes_100.repeat(4) | |
const fileName = 'file.txt'; | |
const file = fs.createWriteStream(path.join(__dirname, fileName)); | |
for (let i = 0; i <= 1e6; i++) { | |
file.write(bytes_400); |
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" | |
"log" | |
"net/http" | |
"os" | |
"github.com/gin-gonic/gin" |
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" | |
"log" | |
"net/http" | |
"os" | |
"github.com/cherihung/go-server-starter/config" |
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 config | |
import ( | |
"fmt" | |
"path" | |
"github.com/spf13/viper" | |
) | |
var appConfigs AppConfiguration |
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
# 1 choose a compiler OS | |
FROM golang:alpine AS builder | |
# 2 (optional) label the compiler image | |
LABEL stage=builder | |
# 3 (optional) install any compiler-only dependencies | |
RUN apk add --no-cache gcc libc-dev | |
WORKDIR /workspace | |
# 4 copy all the source files | |
COPY . . | |
# 5 build the GO program |
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 compose = (...functions) => x => functions.reduce((acc, fn) => fn(acc), x); | |
// compose(fn1, fn2, fn3) | |
const pipe = functions => data => { | |
return functions.reduce( | |
(value, func) => func(value), | |
data | |
); | |
}; |
NewerOlder