Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@dongyuwei
dongyuwei / get_title_and_url.applescript
Last active April 30, 2024 05:02 — forked from vitorgalvao/Get Title and URL.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# Keep in mind that when asking for a `return` after another, only the first one will be output.
# This example is meant as a simple starting point, to show how to get the information in the simplest available way.
# Google Chrome
tell application "Google Chrome" to return URL of active tab of front window
tell application "Google Chrome" to return title of active tab of front window
# Google Chrome Canary
tell application "Google Chrome Canary" to return URL of active tab of front window
tell application "Google Chrome Canary" to return title of active tab of front window
# Chromium
@dongyuwei
dongyuwei / MagickWand-sucks.md
Last active February 15, 2024 12:46
ImportError: MagickWand shared library not found. You probably had not installed ImageMagick library.

Wand==0.3.7, Python 3.4.3, OSX EI Capitan 10.11

when run from wand.image import Image it throw errors:

ImportError: MagickWand shared library not found. You probably had not installed ImageMagick library. Try to install: brew install freetype imagemagick

ok, first I try this:

@dongyuwei
dongyuwei / PIME.md
Last active October 7, 2023 13:39
PIME dev/debug log

build and compile with Visual Studio 2019(same with the Appveyor CI)

test build in vs studio 2022

  1. mkdir /d/dyw-code/PIME-Cmake-build
  2. cd /d/dyw-code/PIME-Cmake-build
  3. cmake -G "Visual Studio 17 2022" -A x64 ../PIME
  4. open PIME.sln in vs studio 2022
@dongyuwei
dongyuwei / cacheable-ng-for.directive.ts
Last active September 18, 2023 01:19
cacheable-ng-for.directive. It's buggy now. Don't use it. I'm testing it.
import {
ChangeDetectorRef,
Directive,
DoCheck, Injector,
Input, OnChanges, SimpleChanges,
TemplateRef,
TrackByFunction,
ViewContainerRef
} from "@angular/core";
@Directive({
@dongyuwei
dongyuwei / cron.sh
Created January 1, 2015 13:53
cron job for nginx server
#crontab -u root -e
# m h dom mon dow command
#*/1 * * * * /bin/sh /opt/code/cron.sh > /dev/null 2>&1
count=`ps -wef|grep sbin/nginx |grep -v grep |wc -l`
if [ "$count" -eq 1 ]; then
echo "The nginx process already run";
else
echo "Start the nginx process now:"
/**
1. 有@3x的优先取@3x, 如 add@3x.png
2. 没有@3x的优先取@2x,如 add@2x.png
3. 没有@3x和@2x的,取图片名称本身,如 add.png
*/
const path = require("path");
const shell = require("shelljs");
const files = {};
@dongyuwei
dongyuwei / init.lua
Created October 17, 2022 07:36
use LUA_INIT to preload inspect.lua, so we can use it in lua.
tail ~/.config/fish/config.fish
`set -gx LUA_INIT @/Users/yuwdong/.init.lua`
cat /Users/yuwdong/.init.lua
```lua
inspect = require('inspect')
ins = inspect
```
@dongyuwei
dongyuwei / test.lua
Last active October 17, 2022 07:08
test inspect.lua and http request with luasocket
local inspect = require('inspect')
local http = require("socket.http")
inspect(http)
r, c, h = http.request('https://www.baidu.com/')
print(r)
print(c)
inspect(h)
@dongyuwei
dongyuwei / foo.test.js
Last active September 17, 2022 12:34
mock a default export function in another module
jest.mock('../utilities/prompt/prompt', () => {
const originalModule = jest.requireActual('../utilities/prompt/prompt');
return {
__esModule: true,
...originalModule,
default: jest.fn((args)=> {
if(args.onConfirm){
args.onConfirm('lost reason')
}
}),
@dongyuwei
dongyuwei / create_snap_shots.rb
Created August 21, 2017 01:50
snapshot design for rails's ActiveRecord model
class CreateSnapShots < ActiveRecord::Migration[5.0]
def change
create_table :snap_shots do |t|
t.integer :user_id
t.string :table_name
t.text :table_data , limit: 4294967295
t.integer :table_id
t.integer :snapshot_id
t.timestamps