Skip to content

Instantly share code, notes, and snippets.

@qar
qar / truncate.css
Created July 5, 2022 06:50 — forked from elky/truncate.css
text-overflow ellipsis with 100% width
/*
Demo: https://jsfiddle.net/elky/f6khaf2t/
<div class="element">
<div class="truncate">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@qar
qar / .gitconfig
Created March 23, 2022 04:50 — forked from Kovrinic/.gitconfig
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "[email protected]:"]
insteadOf = git://github
@qar
qar / index.js
Created February 25, 2021 08:03
register vue components automatically
export default {
install(Vue) {
const context = require.context('.', true /* use subdirectory */, /\.vue$/)
context.keys().forEach(key => {
const component = context(key).default
Vue.component(component.name, component)
})
}
}
@qar
qar / polyfills.js
Created August 19, 2020 04:07
JavaScript Polyfills
/**
* IE9, IE10 and IE11 requires all of the following polyfills.
*/
import 'core-js/es/symbol';
import 'core-js/es/object';
import 'core-js/es/function';
import 'core-js/es/parse-int';
import 'core-js/es/parse-float';
import 'core-js/es/number';
import 'core-js/es/math';
@qar
qar / http.js
Last active July 23, 2020 04:27
Axios config
import axios from 'axios';
import qs from 'qs';
const sharedConfig = {};
const formSubmit = axios.create(Object.assign(sharedConfig, {
transformRequest: [function(data, headers) {
headers['Content-Type'] = 'application/x-www-form-urlencoded';
return qs.stringify(data, { arrayFormat: 'repeat' });
}],
@qar
qar / npm.taobao.sh
Created August 23, 2018 11:19 — forked from 52cik/npm.taobao.sh
npm 淘宝镜像配置
npm set registry https://registry.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs # phantomjs 二进制包镜像
@qar
qar / extract.js
Created August 3, 2016 02:09 — forked from Sennahoi/extract.js
Extract bookmarks from a netscape bookmark file with node.js
var cheerio = require("cheerio"),
fs = require("fs");
fs.readFile('bookmarks.html', "utf-8", function read(err, data) {
if (err) {
throw err;
}
var $ = cheerio.load(data);
$("a").each(function(index, a) {
# For ubuntu/trusty64
# Install basic dependency
apt-get install build-essential
apt-get install libssl-dev
apt-get install libnet-ssleay-perl
apt-get install libcrypt-ssleay-perl
# Install NodeJS
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
apt-get install -y nodejs
@qar
qar / start http-server
Created June 24, 2015 07:41
start http-server on windows
@echo off
for /f "skip=1 delims={}, " %%A in ('wmic nicconfig get ipaddress') do for /f "tokens=1" %%B in ("%%~A") do set "IP=%%~B"
echo Visit: http://%IP%:8000
http-server -p 8000
@qar
qar / coutdown
Created June 18, 2015 05:49
count down
function countDown(duration, display) {
var M = 60;
var H = 60 * M;
var D = 24 * H;
var start = Date.now(),
diff,
minutes,
seconds;