Skip to content

Instantly share code, notes, and snippets.

View void-main's full-sized avatar
💭
I may be slow to respond.

Void Main void-main

💭
I may be slow to respond.
View GitHub Profile
import torch
import triton
import triton.language as tl
import numpy as np
def torch_xyxy2xywh(x):
# Convert nx4 boxes from [x1, y1, x2, y2] to [x, y, w, h] where xy1=top-left, xy2=bottom-right
y = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)
y[:, 0] = (x[:, 0] + x[:, 2]) / 2 # x center
@void-main
void-main / db_test.go
Last active November 22, 2019 17:38
Test Beego ORM with mocked sql driver
package db
import (
"testing"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"time"
@void-main
void-main / VMJsonableObject
Created May 1, 2014 13:38
VMJsonableObject helps developer to easily fill an NSObject with NSDictionary (probably parsed from a JSON string).
// For example, let's define a VMUser class that saves user login info.
// VMUser.h
@interface VMUser : VMJsonableObject
@property (nonatomic)NSString *userId;
@property (nonatomic)NSString *userName;
@property (nonatomic)NSString *email;
@end
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,
1. [x] Go shopping
2. Working..
@void-main
void-main / lib_lister.py
Created April 15, 2013 02:01
Generate the lib file list for Qt .pro file.
from os import listdir
from os.path import isfile, join
mypath = "/path/to/your/lib/folder"
onlyfiles = [ "-l" + f[:-4] for f in listdir(mypath) if (isfile(join(mypath,f)) and f.endswith(".lib")) ]
print " ".join(onlyfiles)
@void-main
void-main / ST2-python-main.sublime-snippet
Last active December 15, 2015 09:09
Sample sublime text 2 snippet, just fillin the boilerplate for python file. Select `New Snippet` from `Tools` menu, copy the gist content to the file, save it as `XXXX.sublime-snippet`, and you are all set. For more detailed information, check it out here: `http://docs.sublimetext.info/en/latest/reference/snippets.html` Attention please, the ext…
<snippet>
<content><![CDATA[
#coding=utf-8
def main():
${1:pass}
if __name__ == '__main__':
main()
@void-main
void-main / AWK_SED_RENAME_GITKEEP
Created September 18, 2012 08:31
Rename placeholder file for git to .gitkeep
# find . -name "temp" | awk '{print "mv "$1" "$1}' | sed s/temp/.gitkeep/4 | sh
#
find . -name "temp" -exec bash -c 'mv $0 `dirname $0`/.gitkeep' {} \;