Skip to content

Instantly share code, notes, and snippets.

@sunnyone
sunnyone / ApacheLogParser.psm1
Created December 15, 2012 03:56
Apache Log Parser for PowerShell
function Read-ApacheLog
{
param(
[Parameter(Mandatory=$true)]
[string]
$Path
)
Get-Content -Path $Path | Foreach-Object {
# combined format
@sunnyone
sunnyone / whitelevel.sh
Created September 27, 2012 14:23
White level detection script
#!/bin/sh
# White level detection script
# Copyright (c) 2012 Yoichi Imai <sunnyone41@gmail.com>
if [ -z "$1" ]; then
echo usage: $0 image
exit 1
fi
FILE="$1"
#!/usr/bin/ruby
# Replace linaria styled`` to vanilla-extract style({})
text = DATA.read
text.gsub!(%r|const (\w+) = styled.*?`(.*?)`|m) do
name = $1
css = $2
#!/usr/bin/ruby
# Replace linaria css`` to panda css({})
text = DATA.read
text.gsub!(%r|css`(.*?)`|m) do
css = $1
list = css.split(/;/).map do |s|
@sunnyone
sunnyone / psxaml.ps1
Created June 11, 2012 04:53
PowerShell XAML Example
Add-Type -AssemblyName presentationframework
[xml]$XAML = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="100" Width="20">
<StackPanel>
<TextBox Name="textWeather" />
<Button Name="buttonGet" Content="Get"/>
@sunnyone
sunnyone / AndroidBluetoothSppClientSample.java
Created September 25, 2013 13:48
Android Bluetooth SPP Client Sample
final String command = "HELO\n";
final UUID sppUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
BluetoothAdapter.getDefaultAdapter();
if (btAdapter == null) {
sendLogMessage("Bluetooth adapter is not available.");
return;
}
sendLogMessage("Bluetooth adapter is found.");
@sunnyone
sunnyone / PowerShellUICulture.ps1
Created November 15, 2013 15:48
Changing PowerShell UICulture
# example: Set-PowerShellUICulture -Name "en-US"
function Set-PowerShellUICulture {
param([Parameter(Mandatory=$true)]
[string]$Name)
process {
$culture = [System.Globalization.CultureInfo]::CreateSpecificCulture($Name)
$assembly = [System.Reflection.Assembly]::Load("System.Management.Automation")
@sunnyone
sunnyone / hello-u8.rs
Last active September 20, 2021 10:13
Windows Unicode conversion in Rust
// Add to Cargo.toml
// [dependencies]
// winapi = "*"
// user32-sys = "*"
extern crate winapi;
extern crate user32;
fn from_wide_ptr(ptr: *const u16) -> String {
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;
@sunnyone
sunnyone / AutoFetch.pm
Created May 30, 2011 15:00
Tiarra DCC auto getter
# -----------------------------------------------------------------------------
# $Id$
# -----------------------------------------------------------------------------
# Auto fetch DCC SEND
# -----------------------------------------------------------------------------
package CTCP::DCC::AutoFetch;
use strict;
use warnings;
use base qw(Module);
use Multicast;
using System;
using System.Collections.Concurrent;
using System.Management.Automation;
using System.Threading;
using System.Threading.Tasks;
namespace AwaitablePSCmdlet
{
public class AwaitablePSCmdlet : PSCmdlet
{