Skip to content

Instantly share code, notes, and snippets.

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

Josh Yu joshyu

💭
I may be slow to respond.
  • dalian,Liaoning, China
  • 05:17 (UTC +08:00)
View GitHub Profile
@joshyu
joshyu / infinitescroll.js
Last active August 29, 2015 14:27 — forked from littleiffel/infinitescroll.js
My directive for infinite scroll
app.directive('infiniteScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
return {
link: function(scope, elem, attrs) {
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
elem.css('overflow-y', 'scroll');
elem.css('overflow-x', 'hidden');
elem.css('height', 'inherit');
scrollDistance = 0;
@joshyu
joshyu / gist:db4cfabbbdc8ee07cb75
Created April 1, 2015 08:57
javascript inheritance
function extend(base, props){
if (!base) {
base = angular.noop;
}
var Class= function(){
return base.apply(this, arguments);
}
Class.prototype = angular.extend(Object.create(base.prototype), {
@joshyu
joshyu / rAF.js
Last active August 29, 2015 14:17 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@joshyu
joshyu / vunits.js
Last active August 29, 2015 14:10 — forked from LeaVerou/vunits.js
/**
* Polyfill for the vw, vh, vm units
* Requires StyleFix from -prefix-free http://leaverou.github.com/prefixfree/
* @author Lea Verou
*/
(function() {
if(!window.StyleFix) {
return;
@joshyu
joshyu / demo.haml
Last active August 29, 2015 14:09 — forked from foo9/demo.haml
!!! 5
%html
%head
%meta(charset="utf-8")
%title="demo"
%script(src="http://code.createjs.com/createjs-2013.02.12.min.js")
%script(src="foo9.createjs.tooltip.js")
:css
canvas {
background: #abc;
@joshyu
joshyu / importsp.ps1
Created September 15, 2014 07:05
sharepoint import list/library
$url = "http://apcndae-dzn493x/testsub"
$pathb = "D:/spCmdlets"
$listtoback = "$pathb/list.txt"
$path = "$pathb/backup"
$specifytitle = $args[0]
if(![string]::IsNullOrEmpty($specifytitle)){
Write-Output "import $specifytitle"
$ff = $path+"/"+ $specifytitle + ".cmp"
Import-SPWeb $url -Path $ff
@joshyu
joshyu / exportsp.ps1
Created September 15, 2014 07:03
sharepoint export list/library
$url = "http://apcndae-dzn493x/campus"
$path = "D:/spCmdlets"
#list includes the title list of the site resource.
$listtoback = "$path/list.txt"
$content= Get-Content $listtoback
if($content.Length -eq 0){
$web = Get-SPWeb $url
$lists = $web.Lists
@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh