Skip to content

Instantly share code, notes, and snippets.

View mojeld's full-sized avatar
👽

Haruy Mohri mojeld

👽
View GitHub Profile
@mojeld
mojeld / ViewController_TextView.m
Last active August 29, 2015 14:25
"NSTextView" NSString, append it with a NSColor
//NSTextView 文字に色を付けてAppendする。
//Xcode6.3 MacOS
-(void)Append2:(NSString*)value1 lov:(NSTextView *)lov color:(NSColor*)cl
{
//dispatch_asyncブロック渡しする為?
dispatch_async(
//dispatch_get_main_queueメインのキューで処理
dispatch_get_main_queue(), ^{//^マークはブロック型(クロージャー)と言う事らしいです。
//↓attributeの入れ物を作る。
NSDictionary *satt = @{ NSForegroundColorAttributeName : cl};
@mojeld
mojeld / func.lua
Last active August 27, 2015 05:28
How to use lua53.dll in C++Builder
function lua_function_string(s)
return "るあ " .. s;
end
function lua_function_int(i)
return 5050 + i;
end
@mojeld
mojeld / uIOSUtils.pas
Created January 9, 2016 10:06 — forked from freeonterminate/uIOSUtils.pas
iOS のステータスバーの色を変える
unit uIOSUtils;
interface
uses
System.UITypes;
procedure SetStatusBarColor(const iColor: TAlphaColor);
implementation
@mojeld
mojeld / holiday_lib.php
Created April 9, 2016 14:33
php 日本の休日判断
<?php
#//
#// 休日かどうかを判定
#//
function DateToHolidayBool( $date_str )
{
$date = strtotime( $date_str );
if( isWeekend( $date ) ){ return true; } // 土日判定
@mojeld
mojeld / Task_and_RunAsync_sample.cs
Created July 23, 2018 04:44
UWP - Task.Run()とDispatcher.RunAsync()を使ってasync/await
private async void Button_ClickAsync(object sender, RoutedEventArgs e)
{
p1.IsEnabled = true;
p1.IsIndeterminate = true;
t1.Text = "5000数えた後時間表示";
await Task.Run(async () =>
{
//何か重たい処理
for (int i = 0; i < 5000; ++i)
{
@mojeld
mojeld / cs_Lambda_test.cs
Created July 23, 2018 06:56
C# Lambda Test
//ラムダ式で渡すための宣言
public delegate void Proc<in T>(T arg1);
//ラムダ引数で渡す関数
private void Lambda_test(Proc<int> f)
{
for (int i = 0; i < 100; ++i)
{
f(i);
}
@mojeld
mojeld / rgb.ps1
Created July 24, 2018 04:38
PowerShell Color文字列 #000000をRGB分割してint型に変換表示
<#
2018.07.24
PowerShell 色文字(#000000)からRGB分けてint変換
セキュリティがかかっている場合はSet-ExecutionPolicy RemoteSigned https://go.microsoft.com/fwlink/?LinkID=135170 を管理者モードで試す
PowerShellで rgb.ps1を実行した後、 > str_to_rgb -color "#00ff00"
#>
function global:str_to_rgb()
{
Param([string]$color)
@mojeld
mojeld / json_analyzer.cpp
Created August 28, 2018 23:12
JSON analysis with UWP VC++2017.
//
// JSON analysis using UWP's JsonObject
//
void cpp_uwp::json_test::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
using namespace Windows::Data::Json;
std::function<void(JsonObject^)> hhge{ [this](JsonObject^ json1) {
std::wstringstream lout;
std::function<void(IJsonValue^, Platform::String^)> foo{
@mojeld
mojeld / uwp_HttpClient.cpp
Created August 29, 2018 10:48
How to use the HttpClient class in Visual C++ 2017
void cpp_uwp::json_test::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
using namespace Windows::Web::Http;
using namespace Windows::Storage::Streams;
ActivityIndicator1->IsActive = true;
IHttpClient^ NetHttp1 = ref new HttpClient();
concurrency::create_task(NetHttp1->GetAsync(ref new Uri("https://うあーるえる"))).then([this](IHttpResponseMessage^ res) {
concurrency::create_task(res->Content->ReadAsBufferAsync()).then([this](IBuffer^ buf) {
std::function<Platform::String ^ (std::string)> Utf8ToPlatformString{ [](std::string stin) {