Skip to content

Instantly share code, notes, and snippets.

View TheFanatr's full-sized avatar

Alex Fanat TheFanatr

View GitHub Profile
@jdah
jdah / network_demo.c
Created January 31, 2024 14:22
the world's most basic client/server
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
static void server() {
// create socket
@jdah
jdah / macro_explanation.c
Created January 31, 2024 14:21
explaining some C macro magic
// so a cool trick with macros in C (and C++) is that since macros inside of
// macros are stille evaluated by the preprocessor, you can use macro names as
// parameters to other macros (and even construct macro names out of out of
// parameters!) - so using this trick if we have some macro like
// this:
#include <stddef.h>
#define MY_TYPES_ITER(_F, ...) \
_F(FOO, foo, 0, __VA_ARGS__) \

Routing in the small

ASP.NET Core 3.0 adds new some infrastructure that makes programming in the small (few methods/classes) more convenient.

These scenarios feel more immediate when you can use local functions, and it really benefits from being able to place attributes on them. In particular, placing attributes on parameters is one of the only ways we can provide expressiveness about where the arguments should come from (injecting a DbContext from services in my example).

Using lambdas is an option as well, but for many of these cases the user wants to explicitly specify the types, so it's a small jump in complexity to a local function.

I'm not sure which of these we'd pick stylistically for our samples/blogs - but I'm sure some users will want to do this and it's come up during our internal discussions. I wanted to pass on the feedback about this feature, we have a concrete use case for it.

#!/usr/bin/env python
import sys, os, time
import tweepy
keys = dict(
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
)
@jakub-g
jakub-g / async-defer-module.md
Last active May 23, 2024 20:32
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@Rich-Harris
Rich-Harris / README.md
Last active September 24, 2023 20:08
first-class binding syntax

A modest proposal for a first-class destiny operator equivalent in Svelte components that's also valid JS.

Svelte 2 has a concept of computed properties, which are updated whenever their inputs change. They're powerful, if a little boilerplatey, but there's currently no place for them in Svelte 3.

This means that we have to use functions. Instead of this...

<!-- Svelte 2 -->
<h1>HELLO {NAME}!</h1>
@SteveSandersonMS
SteveSandersonMS / BlazorForm.cshtml
Created September 21, 2018 16:29
Validation mockup A: explicit <ValidateXyz> components that take a Func<T>
@* Unfortunately this has to be named BlazorForm, not Form, because we can't differentiate based on casing *@
<form onsubmit=@HandleSubmit>
@ChildContent(_context)
</form>
@functions {
private FormContext _context = new FormContext();
[Parameter] protected RenderFragment<FormContext> ChildContent { get; set; }
[Parameter] protected Action<FormContext> OnSubmit { get; set; }
/*
Sample of the output:
[
"GET -> api/monitor/routes",
" -> api/monitor",
"POST -> someRoute/test",
"GET -> api/values",
" -> Error",
"-------- SECURED ROUTES --------",
@McKabue
McKabue / Get_All_Routes_in_ASP.NET_MVC_Core_2.cs
Last active May 11, 2023 07:16
Get all routes, including default routes specified at start up
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Threading.Tasks;

Thoughts on jailbreak detection

The controversy of jailbreak detection has been brought up multiple times in my Twitter feed, so in order to not have to repeat myself, I'll write my thoughts down here.
One day I'll hopefully get round to set up a realistic blog and then I'll move this there, but for now I'll just dump it here on GitHub.

Motivation

Hi. I'm Siguza, and among other things I write exploits for a hobby and help make jailbreaks. One of the reasons I do that is because I believe we should have the ability to run whatever we want on our iDevices, just as we do with laptops and desktop computers. Now, a lot of app developers however seem to despise jailbreaks, and try to make their apps refuse service on jailbroken devices. I think that firstly sucks big time, and secondly always misses the point. From what I gathered, the two arguments for using jailbreak detection seem to be:

  • "J