Skip to content

Instantly share code, notes, and snippets.

View hotdang-ca's full-sized avatar

James Robert Perih hotdang-ca

View GitHub Profile
@akisute
akisute / NetworkInformation.h
Created November 4, 2010 07:28
NetworkInformation.h Objective-C class to retrieve network information. Licensed under MIT License.
//
// NetworkInformation.h
//
// Created by akisute on 10/10/07.
// Copyright 2010 株式会社ビープラウド.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@hotdang-ca
hotdang-ca / dart_mirror.dart
Last active February 3, 2022 20:20
Basic Object name via Reflection in Dart
import 'dart:mirrors';
class User {
final String email;
final String name;
const User({required this.email, required this.name});
}
extension DeclarationMirrorExtension on DeclarationMirror {
/// Name of this object or field
@hotdang-ca
hotdang-ca / example.js
Created July 16, 2019 15:17
CamelCase to Camel Case
console.log("JamesPerihIsCool".replace(/(?<!^)(?=[A-Z])/g, ' '));
@alisterlf
alisterlf / gist:3490957
Created August 27, 2012 18:10
JAVASCRIPT:Remove Accents
function RemoveAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
@FaisalAbid
FaisalAbid / Redis Dart Connection Pool
Last active February 19, 2023 22:06
Redis Dart Connection Pool
library db.redis;
import 'dart:async';
import 'package:redis_client/redis_client.dart';
import 'package:connection_pool/connection_pool.dart';
class Redis {
static Future<RedisClient> getRedis() async {
ManagedConnection managedConnection = await new RedisPool().getConnection();
@webinista
webinista / array.chunk.js
Last active March 29, 2023 23:02
Array.prototype.chunk: Splits an array into an array of smaller arrays containing `groupsize` members
/*
Split an array into chunks and return an array
of these chunks.
With kudos to github.com/JudeQuintana
This is an update example for code I originally wrote 5+ years ago before
JavaScript took over the world.
Extending native objects like this is now considered a bad practice, so use
@OnesimusUnbound
OnesimusUnbound / quote.txt
Last active August 16, 2023 16:24
Programming Quotes
[T]he difference between a bad programmer and a
good one is whether he considers his code or his
data structures more important. Bad programmers
worry about the code. Good programmers worry about
data structures and their relationships.
-- Linus Torvalds
~~~
Clarity and brevity sometimes are at odds.
When they are, I choose clarity.
-- Jacob Kaplan-Moss
@hotdang-ca
hotdang-ca / Keypad.tsx
Last active September 8, 2023 08:58
Numeric Keypad in TypeScript React
import * as React from 'react';
import { KeypadKey } from './KeypadKey';
import './styles.less';
export interface IKeypadProps
{
onKeyPressed: (keyPressed: KeypadKeys) => void;
}
@hotdang-ca
hotdang-ca / distance.go
Last active March 14, 2024 06:58
Golang code to calculate distance between two lat/lng decimal coordinates.
package main
import (
"math"
"fmt"
)
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//::: :::
//::: This routine calculates the distance between two points (given the :::
@mgechev
mgechev / basic-tcp-server.dart
Created June 17, 2013 15:55
Basic TCP server in Dart
import 'dart:core';
import 'dart:async';
import 'dart:io';
void startServer() {
Future<ServerSocket> serverFuture = ServerSocket.bind('0.0.0.0', 55555);
serverFuture.then((ServerSocket server) {
server.listen((Socket socket) {
socket.listen((List<int> data) {
String result = new String.fromCharCodes(data);