Skip to content

Instantly share code, notes, and snippets.

@dhammack
dhammack / Logistic_Regression.ipynb
Created December 21, 2013 16:45
Logistic Regression. Multiclass (softmax) classification, various nonlinear basis functions, training with gradient descent + momentum, comparisons with sklearn's implementation. Based on Bishop 4.3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tinrab
tinrab / action.ts
Last active May 5, 2024 17:00
Calling server actions in client form components
'use server';
export const signUpAction = apiAction(
signUpFormSchema,
async (data): Promise<{ }> => {
// ...
},
);
@ayoubzulfiqar
ayoubzulfiqar / folder_structure.md
Created September 5, 2023 06:12
The Folder Structure for Every Golang Project

Go - The Ultimate Folder Structure

Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:

project-root/
    ├── cmd/
    │   ├── your-app-name/
    │   │   ├── main.go         # Application entry point
    │   │   └── ...             # Other application-specific files
@tatocaster
tatocaster / RealPathUtil.java
Last active May 5, 2024 16:59
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@gruber
gruber / Split Tabs to New Window.scpt
Last active May 5, 2024 16:58
An AppleScript for Safari to move all tabs in the frontmost window, from the current tab to the rightmost (last) tab, to a new window.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
(*
Original script: John Gruber (https://daringfireball.net/linked/2023/12/05/an-applescript-for-safari-split-tabs-to-new-window)
Much more elegant version: Leon Cowle (https://github.com/leoncowle)
Even more elegant version: https://stackoverflow.com/questions/54066100/applescript-to-split-safari-tabs-into-new-window/54089865#54089865
Worth a warning: "moving" tabs with this script doesn't actually move them like
drag-and-drop does. The tabs "moved" by this script will reload in the new window,
@TheCherno
TheCherno / Instrumentor.h
Last active May 5, 2024 16:58
Basic Instrumentation Profiler
//
// Basic instrumentation profiler by Cherno
// Usage: include this header file somewhere in your code (eg. precompiled header), and then use like:
//
// Instrumentor::Get().BeginSession("Session Name"); // Begin session
// {
// InstrumentationTimer timer("Profiled Scope Name"); // Place code like this in scopes you'd like to include in profiling
// // Code
// }
def bin(x, k=0):
d = {0:'000', 1:'001', 2:'010', 3:'011', 4:'100', 5:'101', 6:'110', 7:'111'}
return ''.join([d[int(dig)] for dig in oct(x)]).lstrip('0').zfill(k)
// This work is licensed under the Creative Commons Attribution 3.0 United States License. To view
// a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/ or send a letter
// to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
// Copyright 2009 John Tantalo <john.tantalo@gmail.com>
(function () {
// get selection
var selection = window.getSelection ? window.getSelection() :
document.getSelection ? document.getSelection() :
@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
javascript:(function%20()%20{var%20selection%20=%20window.getSelection%20?%20window.getSelection()%20:document.getSelection%20?%20document.getSelection()%20:document.selection%20?%20document.selection.createRange().text%20:%20%27%27;if%20(selection)%20{selection%20=%20String(selection);}if%20(selection)%20{var%20match%20=%20selection.match(%27\/(.*)\/%27);var%20ipa;if%20(match%20&&%20match[1])%20{ipa%20=%20match[1];}if%20(!ipa)%20{ipa%20=%20prompt(%22Couldn%27t%20find%20any%20IPA.%20Type%20it%20in%20instead?%22);}if%20(ipa)%20{ipa%20=%20ipa.replace(/./g,%20function%20(c)%20{if%20(/%u0(...)/.test(escape(c)))%20{return%20escape(c).replace(/%u0(...)/g,%20%27&#x$1;%27);}%20else%20{return%20c;}});var%20request%20=%20{txt:%20%27<phoneme%20alphabet=%22ipa%22%20ph=%22%27+ipa+%27%22>%20</phoneme>%27,voice:%20%27crystal%27};var%20iframe%20=%20document.createElement(%27iframe%27);iframe.name%20=%20iframe.id%20=%20%22iframe%22+new%20Date().getTime();document.body.appendChild(iframe);var%20form%20=%20document.createElemen