Skip to content

Instantly share code, notes, and snippets.

View moozzyk's full-sized avatar

Pawel Kadluczka moozzyk

View GitHub Profile
var m = Regex.Match("CentOS Linux release 7.1.1503(Core)", @"^(?<distro>\S+) \S+ \S+ (?<version>\d\.\d)\..+$");
if (m.Success)
{
Console.WriteLine($"Distro: {m.Groups["distro"]} Version: {m.Groups["version"]}");
}
{
"userSecretsId": "aspnet-WebApplication1-84f1878e-a871-4f80-baca-de15b99a96d9",
"dependencies": {
"RestSharp": "105.2.3",
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
1. Install/Upgrade carthage package manager (e.g. using brew or pkg) - link to github repo
2. Create a new Cocoa/Swift app
3. Create a new file called `Cartfile` in the application folder
4. Add `github "moozzyk/SignalR-Client-Swift" master` to the file to get the latest version (releases, tags in the future)
5. Run `carthage update --platform macOS` (--platform can be skipped to install for iOS and tvOS)
6. Add SignalRClient and SockertRocket to "Embedded Binaries"
7. Add SignalRClient and SocketRocket to "Linked Frameworks and Libraries" (Note 6. should do this automatically)
8. Add `import SignalRClient` to import SignalR client definitions
9. When using http you will likely see this error:
SignalRApp[14409:1752344] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
~~ Verbose https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqu8z8v/ (vs mine) ~~
~~Inconsistencies (fold - accumulator first in List.fold_left but second in Hashtbl)
print_int (List.fold_left (fun acc line -> max acc (process line registers)) min_int lines);
print_endline "";
print_int (Hashtbl.fold (fun k v acc -> if v > acc then v else acc) registers min_int);~~
Documentation
- lacking, samples very hard to find
- http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html - initally confusing than helpful
~~Regular expressions - match groups~~
~~Basis IO operations - too complicated/missing~~
let is_prime n =
let rec is_prime_aux n div =
if div > int_of_float (sqrt n) then true
else if n mod div = 0 then false
else is_prime_aux n (div + 1)
in
is_prime_aux n 2
(* Error: This expression has type float but an expression was expected of type
int
Points to `n` in `if n mod div...` *)
@moozzyk
moozzyk / gist:5abdc2ff439c179832e143c6a72a3e0a
Last active April 9, 2018 23:44
SignalR Server tracing config
<!--
[‎5/‎19/‎2017 12:05 PM]
Here is config the has all trace sources:
-->
  <system.diagnostics>
    <sources> 
  <source name="SignalR.MessageBus">
        <listeners>
          <add name="SignalR-Bus" />
        </listeners>
@moozzyk
moozzyk / rust
Last active December 31, 2018 05:48
Good documentation/starting guide
Should have read more before starting (e.g. the borrowing concept)
unwrap().unwrap().unwrap() everywhere (likely I am doing something wrong)
iter() vs into_iter() confusing for beginners
regex - quite easy to get it up and running
when is ';' (not) required?
lack of traditional `for` loop - counter needs to be in the loop
pattern matching
lifetimes/borrows are killing me - day 4 - could not return HashMap from a function
hint in errors are helpful:
import * as puppeteer from "puppeteer";
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(
"https://seattle.craigslist.org/search/cta?query=blazer%20k5",
{
waitUntil: "networkidle0",
}