Skip to content

Instantly share code, notes, and snippets.

#!/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 '.'
<%@ 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>
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();
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();
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()
{
}
void Foo(ref string a)
{
a = "hi";
}
void Bar()
{
var x = "bye";
Foo(ref x);
Console.WriteLine(x); // "hi"
public class Program
{
public static int AddOne(this int num)
{
return num + 1;
}
public static void Main(string[] args)
{
Console.WriteLine( 123.AddOne() );
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" : "");
#!/usr/bin/ruby
require '/onramp/bootstrap.rb'
def say(s)
puts "\e[1m#{s}"
end
module Cmdlets
class Add
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