Skip to content

Instantly share code, notes, and snippets.

View Reizinixc's full-sized avatar
🗨️
In the place where the internet is limited

Ichi (Reizinixc) Reizinixc

🗨️
In the place where the internet is limited
  • Japan
  • 00:46 (UTC +09:00)
View GitHub Profile
@Reizinixc
Reizinixc / markAllMigrationsMigrated.php
Created July 9, 2014 15:41
Set all migration files was migrated.
<?php
$host = '127.0.0.1';
$dbname = 'database';
$username = 'root';
$password = '';
$migrationPath = '../app/database/migrations/';
$migrationFiles = array_diff(scandir($migrationPath), ['.', '..', '.gitkeep']);
@Reizinixc
Reizinixc / string.format.js
Created July 16, 2014 13:23
C# style string formatting in JavaScript
/**
* C# style string formatting
*
* @param {...string|...Number} args
* @return {string}
*/
String.prototype.format = String.prototype.format || function() {
return [].reduce.call(arguments, function(formatted, arg, i) {
return formatted.replace('{' + i + '}', arg, 'gi');
}, this);
CREATE TABLE t1 (
id INT UNSIGNED NOT NULL,
name INT UNSIGNED NOT NULL
);
CREATE TABLE t2 (
id INT UNSIGNED NOT NULL,
name INT UNSIGNED NOT NULL
);
@Reizinixc
Reizinixc / cs-stacktrace-regex
Created January 28, 2016 06:38
C# Stacktrace parser regex
(?: *)at (?:(?<namespace>[\w\d_.]*)\.)?(?<class>[\w\d_.]*(\.[\w\d_.<>]+)?)\.(?<method>[\w\d_\[\]<>]*)\((?:(?<parameter>[\w\d_]+(?:\[\]|&|\*)? [\w\d_]+)(?:, )?)*\)(?: *in *(?<file>[^:]+(?::[^:]+)?))?(?::line *(?<line>\d+))?
@Reizinixc
Reizinixc / TryGetValueOrDefault.cs
Created November 27, 2016 16:20
TryGetValueOrDefault for dictionary interface
/// <summary>
/// Gets the value that associated with the specified key in provided dictionary,
/// or returns the default value of the value's type when the key is not associate.
/// </summary>
/// <typeparam name="K">Type of dictionary key.</typeparam>
/// <typeparam name="V">Type of dictionary value.</typeparam>
/// <param name="dict">A dictionary instance to be got the value.</param>
/// <param name="key">A key to be searched in the dictionary.</param>
/// <returns>
/// The value associated with the specified key. If the key is not exist in
@Reizinixc
Reizinixc / project.json
Created February 4, 2017 13:16
Default project.json
{
"version": "1.0.0-*",
"packOptions": {
"owners": [
"Kune Keiseiie"
]
},
"dependencies": {
"NETStandard.Library": "1.6"
},
@Reizinixc
Reizinixc / DbCommandExtensions.cs
Created June 18, 2017 12:01
IDbCommand extension methods
using System;
using System.Data;
using System.Data.Common;
namespace Reizinixc.Common.Database.Extensions
{
/// <summary>
/// Represents an extension class provides methods to be more convenient to work with
/// <see cref="IDbCommand" />.
/// </summary>
@Reizinixc
Reizinixc / patch-server-mirrorer.bash
Last active November 13, 2019 08:31
A script to help mirroring ECO patch server (usage: patch-server-mirrorer.bash «startPullingVersion»)
#!/bin/bash
server=patch.gungho.jp
baseUrl="http://${server}/eco"
curl "${baseUrl}/econew.ver" -o "econew.ver"
latestVersion=`cat econew.ver`
for version in `seq $1 $latestVersion`; do
@Reizinixc
Reizinixc / namespace-generator.js
Created February 6, 2018 02:03
Namespace generator for JavaScript using in website. Cut from the work project.
var namespace = (function (global) {
'use strict';
const separator = '.';
// Inner namespace class for containing the inner namespaces and values.
function Namespace() {
}
return function (namespace) {
@Reizinixc
Reizinixc / JTokenExtensions.cs
Created February 20, 2018 00:32
Code for converting a specified JToken to the dictionary-based type. Best for use with LINQPad to read the information.
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace Reizinixc.Common.Data.Json.Extensions
{
public static class JTokenExtensions
{
public static object ToImmutableObject(this JToken token)