Skip to content

Instantly share code, notes, and snippets.

View silkfire's full-sized avatar
🐬
Infinite is our great adventure

Gabriel Bider silkfire

🐬
Infinite is our great adventure
  • Stockholm, Sweden
View GitHub Profile
@forestrf
forestrf / FastByteConverter.cs
Last active June 30, 2022 07:41
c# structs to convert easily and fast between simple types and an array of bytes
using System;
using System.Runtime.InteropServices;
namespace Ashkatchap.BitUtils {
public enum Endianness {
/// <summary>
/// Network Byte order
/// </summary>
Big = 0,
/// <summary>
@justinsaraceno
justinsaraceno / nadatimeUTCConvert.cs
Last active January 24, 2024 22:23
Convert UTC DateTime to a specified time zone using Noda Time
// the time zone to convert to
var timeZone = DateTimeZoneProviders.Tzdb["US/Eastern"];
// the date as UTC - this could be from a data store
var fakeUtcDate = new DateTime(2015, 11, 01, 07, 30, 00);
// convert to instant from UTC - see http://stackoverflow.com/questions/20807799/using-nodatime-how-to-convert-an-instant-to-the-corresponding-systems-zoneddat
var instant = Instant.FromDateTimeUtc(DateTime.SpecifyKind(fakeUtcDate, DateTimeKind.Utc));
var result = instant.InZone(timeZone).ToDateTimeUnspecified();
@tracker1
tracker1 / 01-directory-structure.md
Last active April 26, 2024 21:26
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used

When you modify a file in your repository, the change is initially unstaged. In order to commit it, you must stage it—that is, add it to the index—using git add. When you make a commit, the changes that are committed are those that have been added to the index.

git reset changes, at minimum, where your current branch is pointing. The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master with this series of commits:

- A - B - C (master)

HEADpoints to C and the index matches C.

--soft

@regularcoder
regularcoder / FletcherChecksum.cs
Created January 4, 2014 11:59
Fletcher's checksum in C#
/*
* Created by SharpDevelop.
* Date: 1/4/2014
* Time: 5:15 PM
*
*
*/
using System;
using System.Text;
using System.Collections.Generic;