View setup.sh
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
# add your ssh public key to github & gitlab | |
# set GOPRIVATE, for github & gitlab | |
GOPRIVATE="gitlab.com/<your-private-group>,github.com/<your-private-group>" | |
# if you use a private hosted gitlab | |
GOPRIVATE="gitlab.yoursite.com" | |
# set github to use ssh | |
git config --global url."git@github.com:".insteadOf "https://github.com/" |
View aes.go
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 cryptor | |
import ( | |
"crypto/aes" | |
"crypto/cipher" | |
"crypto/rand" | |
"encoding/hex" | |
"fmt" | |
"io" | |
) |
View copy-to-clipboard.js
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
javascript:(function() {function copyToClipboard(text) { if (window.clipboardData && window.clipboardData.setData) { /*IE specific code path to prevent textarea being shown while dialog is visible.*/ return clipboardData.setData("Text", text); } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { var textarea = document.createElement("textarea"); textarea.textContent = text; textarea.style.position = "fixed"; /* Prevent scrolling to bottom of page in MS Edge.*/ document.body.appendChild(textarea); textarea.select(); try { return document.execCommand("copy"); /* Security exception may be thrown by some browsers.*/ } catch (ex) { console.warn("Copy to clipboard failed.", ex); return false; } finally { document.body.removeChild(textarea); } }}var markdown = '[' + document.title + '](' + window.location.href + ')';var selection = window.getSelection( |
View Dockerfile
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 nginx:alpine | |
COPY ./build /usr/share/nginx/html | |
COPY nginx.conf /etc/nginx/conf.d/default.conf | |
EXPOSE 80 | |
CMD ["nginx", "-g", "daemon off;"] |
View upload_file_multer.js
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 path = require('path') | |
const fs = require('fs') | |
const express = require('express') | |
const bodyParser = require('body-parser') | |
const multer = require('multer'); | |
const crypto = require('crypto'); | |
const db = require('./db/db.json') |
View sqlmock_test.go
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
// with empty New(), you should use regex `(.+)` and escape the `$` using `\\` | |
db, mock, _ := sqlmock.New() | |
mock.ExpectQuery("SELECT (.+) FROM \"ARTICLES\" WHERE \"SLUG\" = \\$1"). | |
WithArgs("foobar"). | |
WillReturnRows( | |
sqlmock.NewRows(columns).AddRow( | |
"28e8a227-4ebd-43b8-9631-108392ed2ba8", | |
"foobar", | |
"Foobar", | |
"Body foobar", |
View auth_handler.go
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
// AuthHandler handle user auth | |
type AuthHandler interface { | |
Authorize(w http.ResponseWriter, r *http.Request) | |
Login(w http.ResponseWriter, r *http.Request) | |
} | |
type authHandler struct { | |
userService app.UserService | |
} |
View Prim.java
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
// A Java program for Prim's Minimum Spanning Tree (MST) algorithm. | |
// The program is for adjacency matrix representation of the graph | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
public class Prim | |
{ | |
// Number of vertices in the graph |
View handler.go
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 handler | |
import ( | |
"encoding/base64" | |
"encoding/json" | |
"fmt" | |
"log" | |
"net/http" | |
"strconv" | |
"strings" |
View queue.cpp
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> | |
using namespace std; | |
const int maxElmt = 10; | |
struct Queue { | |
int data[maxElmt]; | |
int head; | |
int tail; | |
}; |
NewerOlder