This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Changes file extension, e.g: | |
# $ cext some/file/deeply/nested/file.png .jpg | |
# $ ls some/file/deeply/nested | |
# file.jpg | |
nametokens = ARGV.first.split '.' | |
newext = ARGV[1].split '.' | |
File.rename ARGV.first, (nametokens[-newext.length, newext.length] + newext).join '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Title="" Language="C#" MasterPageFile="~/Super.Master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="AnyHub._default" %> | |
<%@ Import Namespace="AnyHub" %> | |
<asp:Content ID="Content1" ContentPlaceHolderID="content" runat="server"> | |
<div class="notice info" id="anonwarn" runat="server"><%=Context.Trans(Localizable.AnonymousWarning) %></div> | |
<form action="/upload" method="post" enctype="multipart/form-data"> | |
<input type="hidden" name="folder" value="2" id="folderinput" /> | |
<fieldset class="upload"> | |
<div class="fancy"><input type="file" name="Filedata" /></div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class L | |
{ | |
public static Dictionary<string, Language> languages = null; | |
public static string Trans(this HttpContext ctx, Localizable localizable) | |
{ | |
string lang; | |
if(ctx.Request.Headers["Host"].ToLower().Contains(".anyhub.net")) | |
lang = ctx.Request.Headers["Host"].ToLower().Split('.').First(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class L | |
{ | |
public static Dictionary<string, Language> languages = null; | |
public static string Trans(this HttpContext ctx, Localizable localizable) | |
{ | |
string lang; | |
if(ctx.Request.Headers["Host"].ToLower().Contains(".anyhub.net")) | |
lang = ctx.Request.Headers["Host"].ToLower().Split('.').First(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Config | |
{ | |
public string Username { get; set; } | |
public string Password { get; set; } | |
public static readonly string CfgFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "anyhubdesktop.conf"); | |
public Config() | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Foo(ref string a) | |
{ | |
a = "hi"; | |
} | |
void Bar() | |
{ | |
var x = "bye"; | |
Foo(ref x); | |
Console.WriteLine(x); // "hi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static int AddOne(this int num) | |
{ | |
return num + 1; | |
} | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine( 123.AddOne() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string Relative(this DateTime dt) | |
{ | |
var ts = DateTime.Now.ToUniversalTime() - dt; | |
if (ts.TotalMinutes < 1) | |
return string.Format("just now"); | |
if (ts.TotalMinutes < 60) | |
return string.Format("{0} minute{1} ago", (int)ts.TotalMinutes, (int)ts.TotalMinutes != 1 ? "s" : ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require '/onramp/bootstrap.rb' | |
def say(s) | |
puts "\e[1m#{s}" | |
end | |
module Cmdlets | |
class Add |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/sha2' | |
require 'active_support/secure_random' | |
class User < ActiveRecord::Base | |
validates_presence_of :username, :password, :salt | |
def password=(pw) | |
set_salt unless salt | |
write_attribute :password, hash(pw) | |
end |
OlderNewer