Skip to content

Instantly share code, notes, and snippets.

View hfknight's full-sized avatar

fei.io hfknight

View GitHub Profile
@hfknight
hfknight / yum-centos-5-fix.md
Last active August 9, 2019 16:42
CentOS 5 Yum Repository fix
  • Remove all .repo inside /etc/yum.conf.d/ directory
  • create a new repo file CentOS-Valut.repo
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/5.11/os/i386/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
@hfknight
hfknight / node-npm-install.md
Last active December 12, 2018 21:11 — forked from rcugut/node-npm-install.md
Install node & npm on Mac OS X with Homebrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@hfknight
hfknight / git.md
Last active December 7, 2018 14:54

sync master (rebase)

git rebase master
git rebase --continue
git push -f 

overwrite local w/ remote

git reset --hard origin/branch-name

@hfknight
hfknight / mojave_update_error_fix.md
Last active December 12, 2018 21:10
Fix Git Error: "Permission denied (publickey)" after updating mac os (Mojave)

Fix Git Error: "Permission denied (publickey)" after updating mac os (Mojave)

  1. in terminal, type xcode-select --install
  2. in terminal, go to .ssh/, type ssh-keygen -t rsa -C "your_email@example.com". This will create both id_rsa and id_rsa.pub files
  3. copy id_rsa.pub content to github project > add new SSH key
@hfknight
hfknight / visually-hidden.css
Last active March 14, 2018 15:12
Hiding Content Visually but accessible for screen reader
.element-invisible {
position: absolute !important;
height: 1px; width: 1px;
margin: -1px; padding: 0; border: 0;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
@hfknight
hfknight / gist:2eaf5ce22774acc28e4735d3bf01c1f5
Last active February 20, 2018 20:28
Save your Life from failed Windows 10 Updates
In the search box on the taskbar, type cmd.
2.Right-click Command Prompt in the search results and select Run as administrator. (Select Yes, when prompted by the User Account Control.)
3.In the Administrator: Command Prompt window, type the following command and press Enter:
SC config wuauserv start= auto [Press Enter]
SC config bits start= auto [Press Enter]
SC config cryptsvc start= auto [Press Enter]
@hfknight
hfknight / gist:e1ef62e431e5282bb5170dbbf51ec44b
Created January 8, 2018 18:56
[Synology] Transmission Failed to run package service Solution
Edit script var/packages/transmission/scripts/start-stop-status
in start_daemon () block
changed from :
su - ${USER} "PATH=${PATH} ${TRANSMISSION} -g ${INSTALL_DIR}/var/ -x ${PID_FILE}"
to
sudo -u ${USER} /bin/sh -c "PATH=${PATH} ${TRANSMISSION} -g ${INSTALL_DIR}/var/ -x ${PID_FILE}"
@hfknight
hfknight / image-lazyload.js
Created October 12, 2017 15:13
JS Proxy Pattern: Image Lazy Load
// Provide a surrogate or placeholder for another object to control access to it.
// 常用的虚拟代理形式:某一个花销很大的操作,可以通过虚拟代理的方式延迟到这种需要它的时候才去创建
//(例:使用虚拟代理实现图片懒加载)
// 图片懒加载的方式:先通过一张loading图占位,然后通过异步的方式加载图片,等图片加载好了再把完成的图片加载到img标签里面。
var imgFunc = (function() {
var imgNode = document.createElement('img');
document.body.appendChild(imgNode);
return {
setSrc: function(src) {
function MouseWheelHandler(e) {
var e = window.event || e; // old IE support
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
if (delta < 0) // scroll down
// scroll downaction here
else // scroll up
// scroll up action here
}
if (window.addEventListener) {
@hfknight
hfknight / css-sliding-underline-animation.css
Last active June 20, 2017 18:16
CSS Sliding Underline
/* TOP TO BOTTOM */
.sliding-u-t-b {
text-decoration: none;
display: inline-block;
border-bottom: 0px solid transparent;
width: 210px;
transition: 0.5s ease;
height: 25px;
}