Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
private static int[] SelectionSort(int[] value)
{
if (value != null && value.Length > 1)
{
for (var targetIndex = 0; targetIndex < value.Length - 1; ++targetIndex)
{
var minIndex = targetIndex;
for (var index = targetIndex + 1; index < value.Length; ++index)
{
if (value[index] < value[minIndex])
/// <summary>
/// Sort files
/// <code> string folder = "c:\\windows\\";
/// string[] files = Directory.GetFiles(folder);
/// IComparer comp = new FileComparer(FileComparer.CompareBy.FileSize);
/// Array.Sort(files, comp);
/// foreach(string file in files)
/// {
/// Console.WriteLine(file);
/// } </code>
using System.Configuration;
namespace CustomConfigurationSection
{
public class SmtpSettings : ConfigurationSection
{
[ConfigurationProperty("Url", DefaultValue = "smtp.returngis.com", IsRequired = true)]
public string Url
{
get
@huobazi
huobazi / README.md
Last active August 29, 2015 14:06 — forked from chrisbloom7/README.md

Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.

So instead of this:

require 'carrierwave/processing/mini_magick'

@huobazi
huobazi / random.rb
Last active August 29, 2015 14:10 — forked from adambird/random.rb
def random_string
(0...24).map{ ('a'..'z').to_a[rand(26)] }.join
end
def random_symbol
random_string.to_sym
end
def random_integer
rand(9999)
module RandomAttribute
def generate_unique_random_base64(attribute, n)
until random_is_unique?(attribute)
self.send(:"#{attribute}=", random_base64(n))
end
end
def generate_unique_random_hex(attribute, n)
until random_is_unique?(attribute)
ActiveSupport.on_load(:action_controller) do
after_action :set_csrf_cookie_for_angular_js
define_method :set_csrf_cookie_for_angular_js do
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
end
private :set_csrf_cookie_for_angular_js
define_method :verified_request_with_angular_header? do
verified_request_without_angular_header? || form_authenticity_token == request.headers['X-XSRF-Token']
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@huobazi
huobazi / proload.js
Last active August 29, 2015 14:11 — forked from matdombrock/proload.js
//USES JQUERY
var slides = [
"img/Lighthouse.jpg",
"img/Desert.jpg",
"img/Jellyfish.jpg"
];
$(slides).each(function () {
$('<img />').attr('src',this).appendTo('body').css('display','none');
});
@huobazi
huobazi / Order.cs
Last active August 29, 2015 14:11 — forked from dinowang/Order.cs
public enum Order
{
Ascending,
Descending
}