Skip to content

Instantly share code, notes, and snippets.

View URI.g4
// Simple URI parser with ANTLR4
// Omer Faruk Zorlu, Jun 2021
grammar URI;
prog : (segment)+ ;
segment : protocol? host path? ;
protocol : VALID_CHARSET+ PROTOCOL_DELIMITER ;
host : VALID_CHARSET+ ~'/'? ;
path : (VALID_CHARSET | PATH_DELIMITER)+ query? ;
query : VALID_CHARSET? QUERY_DELIMITER query_name_value ;
View strap.scad
$fn = 60;
node_radius = 3;
node_bar_height = 16;
nodes = [40, 50];
node_height = 3;
bend_padding = 4;
bend_height = 1.5;
bend_angle = -5;
View ServiceCollectionExtensions.cs
public static class ServiceCollectionExtensions
{
private static MethodInfo _method;
public static void ConfigureTypeNamed<T>(this ServiceCollection serviceCollection, IConfigurationRoot configuration)
=> ConfigureTypeNamed(serviceCollection, configuration, typeof(T));
public static void ConfigureTypeNamed(this ServiceCollection serviceCollection, IConfigurationRoot configuration, Type type)
{
if (_method == null)
View mapper.cs
namespace Mapping
{
public class Mapper
{
private Configuration _configuration;
public Mapper(Configuration configuration)
{
_configuration = configuration;
}
View LocalizationDemo.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace LocalizationDemo
{
class Program
{
static void Main(string[] args)
View apache-mime-download.ps1
$response = (curl "http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types")
$headerPassed = $False
ForEach ($line in $($response.Content -split '[\r\n]')) {
if ($headerPassed -eq $False) {
$headerPassed = $line.StartsWith("# =")
continue
}
else
{
View JsonNetCharConverter.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace jnbug
{
View ios.segue.sample.swift
import UIKit
class MySegueBase: UIStoryboardSegue
{
open func getDestinationFromPosition(viewFrameSize : CGSize!) -> CGAffineTransform {
return CGAffineTransform(translationX: 2*source.view.frame.size.width, y: 0);
}
open func getSourceTargetPositon(viewFrameSize : CGSize!) -> CGAffineTransform {
return CGAffineTransform(translationX: -viewFrameSize.width, y: 0);
View ServiceResponseMapper.cs
using System;
using AutoMapper;
namespace pp
{
class MainClass
{
public static void Main (string [] args)
{
Mapper.Initialize ((obj) => obj.AddProfile<MyProfile> ());
View ios app icon generator.py
import os, sys
import json
import PIL
from PIL import Image
directory = "output"
if not os.path.exists(directory):
os.makedirs(directory)
with open('Contents.json', 'rwb') as data_file: