Skip to content

Instantly share code, notes, and snippets.

@anchan828
anchan828 / README.md
Last active May 1, 2024 04:26
This is an improvement to allow @nestjs/typeorm@8.1.x to handle CustomRepository. I won't explain it specifically, but it will help in some way. https://github.com/nestjs/typeorm/pull/1233

You need to provide some classes and decorators yourself to maintain the same style as typeorm@2.x.

1. EntityRepository -> CustomRepository

@EntityRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {}

@maicong
maicong / wechatEmoticon.js
Created November 12, 2016 05:38
获取微信表情包
((url, delay) => {
let starTime = new Date().getTime();
let xhr = new XMLHttpRequest();
let times = [];
let style = document.createElement('style');
style.textContent = 'body { background: #fff; } div { display: inline-flex; padding: 0.5rem; } div img { box-shadow: 0 0 5px 0 #8e8e8e; }';
document.head.appendChild(style);
document.body.innerHTML = '';
xhr.open('GET', url, true);
xhr.onload = event => {
@Ben-G
Ben-G / DynamicInit.swift
Last active May 27, 2023 13:30
Dynamically create instance based on type in Swift
protocol Initializable {
init()
}
class A : Initializable {
var content:String
required init() {
content = "TestContent"
}
@alampros
alampros / ToggleFunctionKeys.scpt
Last active July 4, 2016 05:07
AppleScript to toggle "Use all F1, F2, etc. keys as standard function keys" in System Preferences > Keyboard.
--Originally posted by "kiodane" at http://forums.macrumors.com/showthread.php?t=383969
tell application "System Preferences"
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
if UI elements enabled then
tell tab group 1 of window "Keyboard" of process "System Preferences"
click checkbox "Use all F1, F2, etc. keys as standard function keys"
if (do shell script "defaults read -g com.apple.keyboard.fnState") = "1" then
@adam-lynch
adam-lynch / requireNoCache.js
Last active January 4, 2022 01:47
Require a module, without going to Node.js's require cache
var path = require('path');
var _invalidateRequireCacheForFile = function(filePath){
delete require.cache[path.resolve(filePath)];
};
var requireNoCache = function(filePath){
_invalidateRequireCacheForFile(filePath);
return require(filePath);
};
@janily
janily / dateformat
Created August 6, 2013 06:34
日期格式化函数 使用方法 dateFormat('yyyy-MM-dd hh:mm:ss'); dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss');
/**
* 对日期进行格式化,
* @param date 要格式化的日期
* @param format 进行格式化的模式字符串
* 支持的模式字母有:
* y:年,
* M:年中的月份(1-12),
* d:月份中的天(1-31),
* h:小时(0-23),
* m:分(0-59),
@snikch
snikch / gist:3661188
Created September 6, 2012 23:16
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@fengmk2
fengmk2 / WeiboUtil.js
Created February 16, 2012 12:11
新浪微博mid与url互转实用工具
/**
* 新浪微博mid与url互转实用工具
* 作者: XiNGRZ (http://weibo.com/xingrz)
*/
var WeiboUtil = {
// 62进制字典
str62keys: [
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",