Skip to content

Instantly share code, notes, and snippets.

@lpnam0201
lpnam0201 / FizzBuzz.cs
Last active May 16, 2020
FizzBuzz without conditional C#
View FizzBuzz.cs
using System;
public class Program
{
public static void Main()
{
var funcs = new Func<int, string>[4]
{
n => n.ToString(),
n => "Fizz",
@lpnam0201
lpnam0201 / enumerate-dir-with-more-than-100-files.js
Created Jan 30, 2020
FileSystemDirectoryReader.readEntries() only returns 100 entries a time, must be called repeatedly to enumerate all entries.
View enumerate-dir-with-more-than-100-files.js
function readEntriesAsync(reader) {
return new Promise((resolve, reject) => {
reader.readEntries(entries => {
resolve(entries);
}, error => reject(error));
})
}
async function enumerateDirectoryWithManyFiles(directoryEntry) {
let reader = directoryEntry.createReader();
View rebaseSample.sh
git init
echo 'a' > a.txt | git add a.txt | git commit -m 'A'
echo 'b' > b.txt | git add b.txt | git commit -m 'B'
echo 'c' > c.txt | git add c.txt | git commit -m 'C'
git branch feature
git checkout master
echo 'd' > d.txt | git add d.txt | git commit -m 'D'
echo 'e' > e.txt | git add e.txt | git commit -m 'E'
git checkout feature
echo 'f' > f.txt | git add f.txt | git commit -m 'F'
View FB comment, like delete
function test()
{
var rows = document.querySelectorAll('#year_2014 .pam._5shk');
for (var k = 0; k < rows.length; k++) {
var row = rows[k];
var editButton = row.querySelector('._42ft._42fu._4-s1._2agf._p._42gx');
editButton.click();
var possibleDeleteLinks = document.querySelectorAll('a[ajaxify]');
for (var i = 0; i < possibleDeleteLinks.length; i++) {