Skip to content

Instantly share code, notes, and snippets.

View zhangyuan's full-sized avatar

Yuan Zhang zhangyuan

  • Xi'an, China
  • 12:21 (UTC +08:00)
View GitHub Profile
@zhangyuan
zhangyuan / gulpfile.js
Last active July 25, 2017 02:31
convert svg to iconfont
var gulp = require('gulp');
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var runTimestamp = Math.round(Date.now()/1000);
var fontName = 'icons';
gulp.task('iconfont', function(){
return gulp.src(['icons/*.svg'])
.pipe(iconfontCss({
@zhangyuan
zhangyuan / coverage.md
Created July 13, 2017 08:41
Test Coverage Configuration
@zhangyuan
zhangyuan / Dockerfile
Last active June 29, 2017 10:25
Run cucumber inside docker
FROM debian:jessie
RUN apt-get update
RUN apt-get install -y git-core zlib1g-dev libssl-dev build-essential libxml2-dev libxslt-dev curl libreadline-dev unzip xvfb
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
rm /tmp/chromedriver_linux64.zip && \
@zhangyuan
zhangyuan / passport-saml-mock.js
Created June 15, 2017 10:19
A simple mock for passport saml (okta)
const SamlStrategy = require("passport-saml").Strategy;
const oldAuthenticate = SamlStrategy.prototype.authenticate;
export const mockAuthenticate = function (user) {
SamlStrategy.prototype.authenticate = function () {
this.success(user);
};
};
export const mockRedirectToOkta = function () {
@zhangyuan
zhangyuan / steps.rb
Created May 2, 2017 06:41
Load local cookies.txt to browser in Cucumber and Capybara
require "http-cookie" # gem 'http-cookies'
When /^Login domain.local$/ do
visit "https://domain.local/not_found"
cookie_jar = HTTP::CookieJar.new
cookie_jar.load("/path/to/cookies.txt", :cookiestxt)
cookie_jar.each do |cookie|
convert -background transparent -fill rgba(255,0,0,1) -font "Arial" -pointsize 50 label:"Hello" -channel alpha -evaluate multiply 0.35 -trim +repage output.png
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<style>
body {
margin: 0;
padding: 0;
CONTAINER_NAME=${GO_PIPELINE_NAME}_${GO_STAGE_NAME}_${GO_JOB_NAME}
containers=$(docker ps -aq -f name=${CONTAINER_NAME})
if [[ ! -z $containers ]]; then
docker rm -f $containers
fi
# requirements.txt
#
# pydash
# requests
# termcolor
import requests
import pydash
import time
import os
#!/usr/bin/env python
from migrate.versioning import api
url = "sqlite:///project.db"
repository = "migration"
api.version_control(url, repository)
# api.version(repository)
# api.db_version(url, repository)