Skip to content

Instantly share code, notes, and snippets.

View abnerCrack's full-sized avatar
🏠
Working.

C abnerCrack

🏠
Working.
View GitHub Profile
@abnerCrack
abnerCrack / install-sonar-scanner.sh
Last active December 19, 2019 09:20 — forked from chetanppatil/install-sonar-scanner.sh
Install sonar-scanner in linux mint, ubuntu...
#!/bin/bash
cd /tmp || exit
echo "Downloading sonar-scanner....."
if [ -d "/tmp/sonar-scanner-cli-4.0.0.1744-linux.zip" ];then
sudo rm /tmp/sonar-scanner-cli-4.0.0.1744-linux.zip
fi
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.0.0.1744-linux.zip
echo "Download completed."
@abnerCrack
abnerCrack / scale-canvas.js
Created August 10, 2018 07:31 — forked from callumlocke/scale-canvas.ts
Function to fix a canvas so it will look good on retina/hi-DPI screens.
/**
* This function takes a canvas, context, width and height. It scales both the
* canvas and the context in such a way that everything you draw will be as
* sharp as possible for the device.
*
* It doesn't return anything, it just modifies whatever canvas and context you
* pass in.
*
* Adapted from Paul Lewis's code here:
* http://www.html5rocks.com/en/tutorials/canvas/hidpi/
@abnerCrack
abnerCrack / use-node-open-terminal.md
Created June 6, 2018 10:37 — forked from neekey/use-node-open-terminal.md
在nodeJS中启动一个teminal窗口执行相关进程

Mac

使用open 命令,调用terminal来打开abc这个文件:

open -a /Applications/Utilities/Terminal.app "abc"

期中-a这个参数保证打开一个新的terminal实例

@abnerCrack
abnerCrack / app.js
Created April 29, 2017 18:05 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@abnerCrack
abnerCrack / gist:501e6c96655f8fa5838fba3fb85d78f6
Created August 22, 2016 08:02 — forked from ndrut/gist:4549230
Render an image in base64 using phantom js. Convert the base64 into a raw binary buffer, pass the binary buffer to GraphicsMagic which can write to a writable stream, collect the chunks of data in separate buffers, storing them in an array and then concatenate them all together.
// PhantomJS Render to base64 function
page.renderBase64('png', function(err, img) {
var image = {};
image.thumb = [];
final.full = new Buffer(img, 'base64'); // Convert the base64 encoded value into binary.
var thumbStream = new stream.Stream(); // Create a new writable stream
thumbStream.writable = true;
thumbStream.write = function (chunk) {
image.thumb.push(chunk); // Take the data written and store it into an array
@abnerCrack
abnerCrack / mysql2sqlite.sh
Created July 14, 2016 09:17 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
##########################################
# To run:
# curl -sSL https://gist.githubusercontent.com/sirkkalap/e87cd580a47b180a7d32/raw/d9c9ebae4f5cf64eed4676e8aedac265b5a51bfa/Install-Docker-on-Linux-Mint.sh | bash -x
##########################################
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi
@abnerCrack
abnerCrack / express.md
Created December 11, 2015 14:28 — forked from dlutwuwei/express.md
express4.2源码解析

title: express4.2源码解析 date: 2014-05-18 15:00:50 categories: express tags: [nodejs, node, js, express]

express是nodejs平台上一个非常流行的框架,4.2.0是最新的版本,相比3.x版本优化了代码和api,去除了connect模块,自己实现了一个router组件,实现http请求的顺序流程处理,去除了很多绑定的中间件,使代码更清晰。

##1.使用express 如何使用express在官网有很好的讲解,只用experssjs实例app的几个函数,就可以构建构建web程序。

// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
// 典型自执行函数格式:
// (funtion(root, factory) {
// // do stuff here