Skip to content

Instantly share code, notes, and snippets.

View Luxiyalu's full-sized avatar

Lucia Lu Luxiyalu

View GitHub Profile
https://github.com/Doist/backend-issues/issues/2284
https://github.com/Doist/backend-issues/issues/2566
https://github.com/Doist/backend-issues/issues/2290
https://github.com/Doist/backend-issues/issues/2303
https://github.com/Doist/backend-issues/issues/2026
https://github.com/Doist/backend-issues/issues/2282
https://github.com/Doist/backend-issues/issues/2388
https://github.com/Doist/backend-issues/issues/2555
@Luxiyalu
Luxiyalu / delay_ass.js
Created February 28, 2019 08:04
Delay ASS subtitles by certain seconds.
// USAGE:
// node delay_ass.js subtitle.ass -32
const fs = require('fs');
const fileName = process.argv[2];
const delaySeconds = process.argv[3];
const encoding = process.argv[4] || 'utf16le';
if (typeof delaySeconds === 'undefined') {
console.log(
@Luxiyalu
Luxiyalu / clean_up_kinde_documents_dir.rb
Created June 24, 2015 02:47
Rid the kindle "documents" directory of unnecessary *.sdr record files. Optional parameter: full path of the documents directory.
require 'FileUtils'
root = ARGV[0] || "/Volumes/Kindle/documents"
all_files = Dir[root + "/*"]
rec_files = all_files.find_all{ |f| f.end_with?(".sdr") }
# doc_types = ['txt', 'pdf', 'mobi', 'azw']
doc_files = all_files.find_all do |f|
f.end_with?("mobi") ||
f.end_with?("pdf") ||
[
{"name": "Afghanistan", "code": "AF"},
{"name": "Åland Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "AndorrA", "code": "AD"},
{"name": "Angola", "code": "AO"},
{"name": "Anguilla", "code": "AI"},
{"name": "Antarctica", "code": "AQ"},
@Luxiyalu
Luxiyalu / AppCtrl.coffee
Last active August 29, 2015 14:07
AngularJS: Click Outside of Directory
app.controller 'AppCtrl', ($rootScope) ->
# broadcast click event within AppCtrl
$(document).on 'click', (e) ->
$rootScope.$broadcast 'click', e.target
# this target is a js dom element
@Luxiyalu
Luxiyalu / checkbox.coffee
Last active August 29, 2015 14:07
AngularJS Directive: Checkbox Set
app.directive 'checkbox', (Page) ->
# Page should be refreshed upon entering the page, within page controller
restrict: 'E'
scope:
hook: '@'
hookedTo: '@'
checkedStoredIn: '='
templateUrl: 'checkbox.html'
link: (scope, element, attr) ->
hookName = scope.hook || scope.hookedTo
@Luxiyalu
Luxiyalu / sticky.coffee
Created September 30, 2014 09:10
AngularJS Directive: {Position: Sticky}
# to provide a fallback for the new CSS property, position: sticky;
# which let an element stays where it is when it's within the screen
# and when it's disappearing into the top of the page with scrolling,
# change the position's behavior to fix.
app.directive 'sticky', ($window, WindowObj) ->
restrict: 'A'
link: (scope, element, attr) ->
sticky = undefined
originalOffsetY = element[0].offsetTop
@Luxiyalu
Luxiyalu / scroll.coffee
Created September 30, 2014 09:05
AngularJS Directive: Scroll
app.directive 'scroll', ($window) ->
restrict: 'A'
($scope, $element, $attr) ->
win = angular.element($window)
$scope.$watch ->
scrollX: window.scrollX
scrollY: window.scrollY
, (newVal, oldVal) ->
$scope.scrollX = newVal.scrollY
@Luxiyalu
Luxiyalu / resize.coffee
Last active August 29, 2015 14:07
AngularJS Directive: Resize
# dependency: jQuery
app.directive 'resize', ($window) ->
restrict: 'A'
($scope, $element, $attr) ->
win = angular.element($window)
$scope.$watch ->
w: win.width()
h: win.height()
, (newVal, oldVal) ->
@Luxiyalu
Luxiyalu / disable-ng-animate.coffee
Created September 30, 2014 08:49
AngularJS Directive: Disable Ng-Animate
# use: fix the bug when angular-ui-bootstrap slider flickers
app.directive 'disableNgAnimate', ($animate) ->
restrict: 'A'
link: ($scope, $element) -> $animate.enabled(false, $element)