Skip to content

Instantly share code, notes, and snippets.

@BlackPrincess
BlackPrincess / gist:4564426
Created January 18, 2013 13:02
MVC3 LabelFor拡張
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using System.Linq.Expressions;
public static class LabelExtensions
{
public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object htmlAttributes)
@BlackPrincess
BlackPrincess / jquery.unobtrusive-ajax.js
Created January 22, 2013 07:52
jquery.unobtrusive-ajax.jsがJQuery 1.9.0でエラーが出てたので、とりあえずエラーだけ消したやつ
/*!
** Unobtrusive Ajax support library for jQuery
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
/*global window: false, jQuery: false */
(function ($) {
var data_click = "unobtrusiveAjaxClick",
@BlackPrincess
BlackPrincess / Color.js
Last active December 11, 2015 20:09
javascriptでColorクラス。 探しても見つけられなかったので自作してみた
function Color(r, g, b) {
var _r = r ? r : 0;
var _g = g ? g : 0;
var _b = b ? b : 0;
function getColorValue(value){
if(value > 255) {
return 255;
}else if(value < 0) {
return 0;
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assem => assem.GetTypes()
.Select(t => t)
.Where(t => t.FullName.Contains("Namespace.Foo"))
.Where(t => Attribute.GetCustomAttributes(t, typeof(BarAttribute)).Length > 0)
.Select(t => t)
);
foreach(Type typ in types)
{
@BlackPrincess
BlackPrincess / gist:5531149
Created May 7, 2013 08:38
jquery distinct(仮)
$.extend({
distinct: function (array) {
var u = {}, a = [];
for(var i = 0, l = array.length; i < l; ++i){
if(u.hasOwnProperty(array[i])) {
continue;
}
a.push(array[i]);
u[array[i]] = 1;
}
@BlackPrincess
BlackPrincess / datepicker.css
Last active December 17, 2015 02:39
todc-bootstrapで使うように合わせてみた
/*!
* Datepicker for Bootstrap
*
* Copyright 2012 Stefan Petre
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*/
.datepicker {
top: 0;
@BlackPrincess
BlackPrincess / pre-commit
Last active December 17, 2015 02:49
PHPのシンタックスエラーチェック
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
if `git rev-parse --verify HEAD 2>/dev/null`
then
against="HEAD"
else
# Initial commit: diff against an empty tree object
against="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
end
Date.prototype.getMonthLength = function() {
return this.getMonthLast().getDate();
}
Date.prototype.getPrevMonth = function() {
return this.dateAdd("month", -1);
}
Date.prototype.getNextMonth = function() {
@BlackPrincess
BlackPrincess / jquery.input.js
Created May 16, 2013 08:53
デフォルトで入力補助をするjs
$("input[data-type=integer]").on("blur", function(){
var value = $(this).val();
if(!$.isNumeric(value)) {
$(this).val("");
return;
}
$(this).val(Math.floor(value));
});
$("input[data-type=float]").on("blur", function(){
@BlackPrincess
BlackPrincess / smoothScroll
Last active December 18, 2015 00:29
適当にかいたスクロール上書き
$(function(){
var currentScroll = 0;
var smoothScroll = function(event){
var delta = 0;
if (!event) /* IE */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta/120;
if (window.opera) {
delta = -delta;