Skip to content

Instantly share code, notes, and snippets.

View GeekaholicLin's full-sized avatar
💭
I may be slow to respond.

void GeekaholicLin

💭
I may be slow to respond.
View GitHub Profile
@GeekaholicLin
GeekaholicLin / arguments_slice.md
Last active December 6, 2016 13:59
如何将arguments转换为参数数组--javascript

问题的由来

在看js编程风格的时候,遇到了一个比较常见的问题:

使用 Array#slice 将类数组对象转换成数组。

function trigger() {
  var args = Array.prototype.slice.call(arguments);
  ...
}
@GeekaholicLin
GeekaholicLin / call_and_apply.md
Last active December 6, 2016 13:13
the trick of using call and apply together[当call和apply一起使用]

在看Javascript 秘密花园的时候,发现一段晦涩难懂的代码片段,由于 中文版的没有讲到这个技巧的妙处,所以硬着头皮,看看英文版

Another trick is to use both call and apply together to turn methods - functions that use the value of this as well as their arguments - into normal functions which only use their arguments.

(大概的意思是:可以一起使用callapply将使用this和参数的方法函数转化为使用相同参数的普通函数), 这不是在普通函数中利用callapply,绑定传入的上下文吗?嗯...挺类似的,但是它两个一起使用,因为上下文是一个函数,需要再利用一次。

全部代码如下

@GeekaholicLin
GeekaholicLin / jq_instantiation,md
Last active December 9, 2016 14:34
jQuery instantiation
在跟着视频一起阅读jQuery的2.0.3源码的时候,发现一个'有意思'的地方,或者说巧妙的地方。
css()等方法是在jQuery原型属性`prototype`的下面定义的,比如jQuery.prototype.css = function(){//do sth.}
但是,我们在调用css()方法的时候,首先使用`$()`[也就是`jQuery()`]获取到一个元素对象,从而调用,例如`$('#top').css();`。但是在源码当中,
当调用jQuery()的时候其实拿到的是init()构造函数的实例。而不是jQuery()构造函数的实例。【因为是jQuery()构造函数的实例,才会向上搜素到该实例的原型对象中的css()等方法】
```javascript
jQuery = function( selector, context ) {
@Sg4Dylan
Sg4Dylan / bilibili_download_them_all.py
Last active April 15, 2023 16:32
通过You-get批量下载Bilibili合集视频
#!/usr/bin/env python
#coding:utf-8
# Author: Sg4Dylan --<sg4dylan#gmail.com>
# Purpose: A simple script to download video from Bilibili
# Created: 08/07/2016
import sys
from subprocess import call
def check_and_go(args):
@hexchain
hexchain / 51-noto-color-emoji.conf.xml
Last active July 7, 2020 23:42
Emoji on Linux desktop. Use with aur/cairo-coloredemoji.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/conf.avail/51-noto-color-emoji.conf -->
<fontconfig>
<selectfont>
<acceptfont>
<pattern>
<patelt name="family"><string>Noto Color Emoji</string></patelt>
</pattern>
</acceptfont>
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@chrisjlee
chrisjlee / querySelector.polyfill.js
Created February 12, 2014 17:39
IE document.querySelector() polyfill
if (!document.querySelectorAll) {
document.querySelectorAll = function (selectors) {
var style = document.createElement('style'), elements = [], element;
document.documentElement.firstChild.appendChild(style);
document._qsa = [];
style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
window.scrollBy(0, 0);
style.parentNode.removeChild(style);
@magnetikonline
magnetikonline / README.md
Last active March 14, 2024 22:48
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.
/*
* Minimal classList shim for IE 9
* By Devon Govett
* MIT LICENSE
*/
if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') {
Object.defineProperty(HTMLElement.prototype, 'classList', {
get: function() {