Skip to content

Instantly share code, notes, and snippets.

View Mufanc's full-sized avatar

Mufanc

View GitHub Profile
@mike820324
mike820324 / SystemCallHooking.c
Created June 27, 2014 18:43
An example of Hooking Linux System Call
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <asm/unistd.h>
#include <asm/pgtable_types.h>
#include <linux/highmem.h>
#include "hook_function_ptr.h"
@hjr3
hjr3 / rust-naming-conventions.md
Created October 20, 2016 14:28
Rust Naming Conventions
Convention Example General Meaning
to_*() str::to_string() A conversion from one type to another that may have an allocation or computation cost. Usually a Borrowed type to Owned type.
as_*() String::as_str() Convert an Owned type into a Borrowed type. It is usually cheap (maybe even zero-cost) to use this function.
into_*() String::into_bytes() Consume a type T and convert it into an Owned type U.
from_*() SocketAddr::from_str() Create an Owned type from an Owned or Borrowed type.
*_mut() str::split_at_mut() Denotes a mutable reference.
try_*() usize::try_from() Method will return a Result or Option type. Usually Result.
with_*() Vec::with_capacity() A constructor that has one or more parameters used to configure the type.
@nickbutcher
nickbutcher / MainActivity.kt
Last active February 22, 2024 21:17
Demonstrating how to tile a (Vector) Drawable
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@RikkaW
RikkaW / gist:be3fe4178903702c54ec73b2fc1187fe
Last active March 26, 2024 14:45
show window in app_process (impossible to work from Android 14 QPR 3 or Android 15, as addView requires the calling process an Android app process)
token = new Binder();
try {
Context _context = android.app.ActivityThread.systemMain().getSystemContext();
final Context context = new ContextWrapper(_context) {
@Override
public Object getSystemService(String name) {
if (Context.WINDOW_SERVICE.equals(name)) {
WindowManager wm = (WindowManager) super.getSystemService(name);
if (wm != null) {
((android.view.WindowManagerImpl) wm).setDefaultToken(token);
@wyl8899
wyl8899 / spacing.ts
Created September 29, 2020 17:48
JavaScript 实现中英文空格 - Implementation
/* Partial implementation from https://zhuanlan.zhihu.com/p/33612593 */
import _ from 'lodash';
/* 标点 */
const punctuationRegex = /\p{Punctuation}/u;
/* 空格 */
const spaceRegex = /\p{Separator}/u;
/* CJK 字符,中日韩 */
const cjkRegex = /\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}|\p{Script=Hangul}/u;
@FreddieOliveira
FreddieOliveira / docker.md
Last active July 25, 2024 00:50
This tutorial shows how to run docker natively on Android, without VMs and chroot.

Docker on Android 🐋📱

Edit 🎉

All packages, except for Tini have been added to termux-root. To install them, simply pkg install root-repo && pkg install docker. This will install the whole docker suite, left only Tini to be compiled manually.


Summary

@vvb2060
vvb2060 / am_proc_start.cpp
Created July 19, 2022 17:12
monitor app process start
#include <unistd.h>
#include <string>
#include <cinttypes>
#include <android/log.h>
#include <sys/system_properties.h>
using namespace std;
extern "C" {