Skip to content

Instantly share code, notes, and snippets.

@sharow
sharow / swapped_process.py
Last active August 29, 2015 14:04
show swapped processes
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import sys
import subprocess
from operator import itemgetter
def show_swapped_processes():
p = subprocess.Popen('grep VmSwap /proc/*/status',
@sharow
sharow / gist:54ddcfef524ce5e5473e
Created June 29, 2015 17:37
type annotation validator
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import inspect
from functools import wraps
class AnnotationValidateError(Exception):
pass
@sharow
sharow / prettyrepr.py
Last active December 15, 2015 17:09
another repr() implementation. readable JSON(or some object) formatter. multibyte string, cut long string.
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
""" prettyrepr.py - another repr() implementation
"""
import sys
version_major = sys.version_info[0]
if version_major == 3:
# python3.x
using UnityEngine;
//using UnityEditor;
using System.Collections;
using System.Collections.Generic;
//[ExecuteInEditMode]
//[AddComponentMenu("Foo/Bar")]
//[RequireComponent(typeof(Foo))]
//[System.Serializable]
@sharow
sharow / 81-C# Script-NewBehaviourScript.cs
Created November 27, 2013 14:23
for Unity\Editor\Data\Resources\ScriptTemplates\
using UnityEngine;
//using UnityEditor;
using System.Collections;
using System.Collections.Generic;
//[ExecuteInEditMode]
//[AddComponentMenu("Transform/Foo")]
//[RequireComponent(typeof(Foo))]
//[System.Serializable]
@sharow
sharow / isarchival.py
Created February 21, 2016 12:45
windows::FILE_ATTRIBUTE_ARCHIVE scanner
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import sys
import ctypes
from pathlib import Path
from contextlib import suppress
# https://msdn.microsoft.com/ja-jp/library/windows/desktop/gg258117%28v=vs.85%29.aspx
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sharow
sharow / linear_regression.ipynb
Last active May 23, 2016 04:28
Machine Learning by Andrew Ng: II. Linear Regression with One Variable (Week 1)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sharow
sharow / rust_bmfont.rs
Created October 11, 2017 13:40
Rust code fragment. load BMFont xml geometries.
extern crate xml;
use std::path::Path;
use std::fs::File;
use xml::reader::EventReader;
use xml::reader::events::*;
#[derive(Clone)]
struct GlyphGeometry {
pub rect: Rect,