Skip to content

Instantly share code, notes, and snippets.

View noru's full-sized avatar
🎮
Working from home

xiuxiuxiu noru

🎮
Working from home
View GitHub Profile
@frankshearar
frankshearar / fake-http-context.cs
Created February 21, 2011 21:28
A Moq-using fake HTTP context to test controllers.
public HttpContextBase FakeHttpContext() {
var context = new Mock<HttpContextBase>();
var files = new Mock<HttpFileCollectionBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
var user = new Mock<IPrincipal>();
var identity = new Mock<IIdentity>();
request.Setup(req => req.ApplicationPath).Returns("~/");
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active July 25, 2024 03:38
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@kikoanis
kikoanis / MvcMockHelpers.cs
Created October 25, 2012 22:11 — forked from rally25rs/MvcMockHelpers.cs
MvcMockHelpers.cs - Helper Utility for Mocking MVC3 Controllers with Moq.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Moq;
/// <summary>
/// This helper class can be used to set up Moq mocks of MVC3/4 controllers.
@mahata
mahata / random.scala
Last active June 5, 2021 20:38
random ascii string generator in Scala
object randomSample {
def randomString(length: Int) = Stream.continually(util.Random.nextPrintableChar) take length mkString
}
println(randomSample.randomString(64))
@mderazon
mderazon / ClearableAutoCompleteTextView.java
Last active November 30, 2018 16:42
a sub class of AutoCompleteTextView that has a dismiss button with OnClearListener when the clear button is clicked
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AutoCompleteTextView;
/**
* sub class of {@link android.widget.AutoCompleteTextView} that includes a clear (dismiss / close) button with
* a OnClearListener to handle the event of clicking the button
@willprice
willprice / .travis.yml
Last active June 15, 2024 04:29
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
@cngdean
cngdean / gist:3702b7be4b6d298dd69c
Last active July 16, 2018 13:17
scala hackerrank i/o stdin stdout
object hackerrank {
object Solution {
def main(args: Array[String]) {
def fact(n: Int): Int = if (n == 1) 1 else n * fact(n - 1)
for (n <- io.Source.stdin.getLines) {
print(fact(Integer.parseInt(n.toString)) + "\n")
}
}
}
var revealJS = function(s) {
var hexAlphabet = Array.apply(null, {
length: 10
}).map(Number.call, Number).concat('abcdef'.split(''));
var codes = [8289, 8204, 8205, 8206, 8207, 8234, 8235, 8236, 8237, 8238, 8298, 8299, 8300, 8301, 8302, 8303];
return s.match(/(.{4})/g).map(function(b) {
return b.split('').map(function(i) {
return hexAlphabet[codes.indexOf(i.charCodeAt())]
})
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active June 19, 2024 18:05
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@paulirish
paulirish / what-forces-layout.md
Last active July 27, 2024 18:06
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent