Blog

  • math-percentage

    Percentage

    Codacy grade Codacy coverage

    Percentage calculations made easy.

    Installation

    Add Percentage to your Gradle build script:

    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation("com.eriksencosta.math:percentage:0.3.0")
    }

    If you’re using Maven, add to your POM xml file:

    <dependency>
        <groupId>com.eriksencosta.math</groupId>
        <artifactId>percentage</artifactId>
        <version>0.3.0</version>
    </dependency>

    Usage

    The library provides the Percentage type: an immutable and thread-safe class that makes percentage calculations easy.

    150 * 5.5.percent()          // 8.25
    150 decreaseBy 5.5.percent() // 141.75
    150 increaseBy 5.5.percent() // 158.25

    Under the hood, all calculations are done by the immutable and thread-safe Percentage class. You can always query for the percentage’s original value, and its decimal representation (i.e., its value divided by 100):

    val percentage = 5.5.percent()
    percentage.decimal // 0.055
    percentage.value   // 5.5

    Rounding

    If you need to round the resulting calculations using a Percentage, just pass an instance of the Rounding class to the percent() method. Use the Rounding.to() factory method to create the object, passing the number of decimal places and the desired rounding mode:

    val percentage = 11.603773.percent()
    val roundsFloor = 11.603773.percent(Rounding.to(2, RoundingMode.FLOOR))
    
    val value = 127
    value * percentage  // 14.73679171
    value * roundsFloor // 14.73

    The rounding mode to use is defined by one of RoundingMode enum values. If you need to use HALF_EVEN, just pass the number of desired decimal places:

    val roundsHalfUp = 11.603773.percent(2)
    value * roundsHalfUp // 14.74

    Other utilities

    Create a Percentage based on a ratio

    To create a Percentage based on a ratio (e.g. 1/2, 1/3, 1/4, and so on), use the ratioOf() function:

    1 ratioOf 4 // 25%
    1 ratioOf 3 // 33.33%

    The function also has overloaded versions to control the rounding strategy of the returned Percentage object:

    // rounds using 2 decimal places and with RoundingMode.HALF_EVEN
    1.ratioOf(3, 2)
    
    // rounds using 2 decimal places and with RoundingMode.UP
    1.ratioOf(3, Rounding.to(2, RoundingMode.UP))

    Calculate the relative change as a Percentage for two numbers

    To calculate the relative change between two numbers, use the relativeChange() function:

    1 relativeChange 3 // 200%
    3 relativeChange 1 // -66.67%

    The function also has overloaded versions to control the rounding strategy of the returned Percentage object:

    // rounds using 2 decimal places and with RoundingMode.HALF_EVEN
    3.relativeChange(1, 2)
    
    // rounds using 2 decimal places and with RoundingMode.UP
    3.relativeChange(1, Rounding.to(2, RoundingMode.UP))

    Calculate the base value of a number when it’s a given Percentage

    To calculate the base value of a number when it’s a given Percentage, use the valueWhen() function:

    5 valueWhen 20.percent() // 25.0

    In other words, the function helps to answer the question “5 is 20% of what number?”

    Code examples

    The UsageExamples file has more examples of calculations using the Percentage library.

    API documentation

    Read the API documentation for further details.

    License

    The Apache Software License, Version 2.0

    Visit original content creator repository
  • BoardTemplate

    Board Template Project

    Node.js를 기반으로 제작한 게시판 템플릿으로, 기본적인 웹 사이트 디자인과 게시판 기능들을 제작해둔 프로젝트 입니다. 공부 및 타 프로젝트에 쉽게 적용하기 위해 제작하게 되었으며 버그 및 개선에 대해서 다양한 피드백 부탁드립니다.

    Database Setting

    Create Database

    > use btDB

    Auto Increment function

    > function autoInc(id) {
    	var ret = db.incCol.findAndModify({
    		query:{_id:id},
    		update: {$inc: {incNum:1}},
    		"new":true,
    		upsert:true
    	});
    	return ret.incNum;
    }

    임시 데이터를 생성하기 이전에 MongoDB에서의 auto increment를 위해 위 함수를 선언해 주시길 바랍니다. auto increment가 작동하는 방식이라면, 꼭 위의 함수를 사용하지 않아도 됩니다.

    Insert BBS Temp Data

    > db.bbs.insertMany([
        {idx:autoInc("bbs"), title:"This is temp Title _ 0", author:"kyechan", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 1", author:"John", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 2", author:"Andrew", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 3", author:"Henry", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 4", author:"Park", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 5", author:"Kim K", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 6", author:"Park", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 7", author:"Yahn", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 8", author:"kyechan", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 9", author:"Kang", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 10", author:"Henry", date:new Date()},
        {idx:autoInc("bbs"), title:"This is temp Title _ 11", author:"Andrew", date:new Date()}
    ])

    임시 데이터들입니다. If you need more temp data -> moreTempData

    Insert User Temp Data

    > db.users.insertMany([
        {idx:autoInc("users"), id:"test", pw:"test"},
        {idx:autoInc("users"), id:"root", pw:"1234"},
        {idx:autoInc("users"), id:"kyechan", pw:"1234"},
        {idx:autoInc("users"), id:"John", pw:"1234"}
    ])

    Preview

    Visit original content creator repository
  • reflow

    Reflow 🚀

    An opinionated workflow tool for Typescript projects 🚀

    Reflow is aimed at reducing the complexity in setting up a proper dev environment for typescript projects.

    Features

    Installation

    Install locally:

    npm install @eriicafes/reflow

    And initialise:

    npx reflow init

    Or install both globally and locally (preferred):

    npm install -g @eriicafes/reflow # global
    
    npm install @eriicafes/reflow #local

    And initialise:

    reflow init

    With a global installation you will not be required to use npx. Global installation is preferred as reflow still requires a local installation and will always run the locally installed binary when available.

    Usage/Examples

    Examples below assume you have both a global installation and a local installation, for local installation only you will have to prefix the command with npx

    All commands have a -h or --help flag to display a help message.
    Nearly all commands have a -d or --dry-run flag useful to see the commands that would run without actually making any changes.
    Command arguments in square brackets [] are optional while those in angle brackets <> are required.

    Initialise reflow workspace

    reflow init
    
    Options:
      -n --no-install  turn off automatic package installation
      --lib            initialize as an npm library

    Branching

    create and checkout new branch

    reflow branch [name] [parent]

    rename the current branch

    reflow branch -r [name]

    Checkout

    reflow checkout [branch]

    checkout with search on branches (this examples searches for all branches beginning with feat)

    reflow checkout feat

    Merge

    merge branch to the main branch (whether on the main branch or on the branch to be merged)

    reflow merge
    
    Options:
      --prefer-ff   always perform a fast-foward merge (default: false)

    Commit

    reflow commit
    
    Options:
      --retry     retry last commit attempt

    Push

    push branch to remote (prompts to sets upstream if not available)
    force push is a bit less dangerous as the following flags are attached -f --force-with-lease --force-if-includes

    reflow push
    
    Options:
      -f --force  force push

    Release

    make a release (bump version, tag commit and push changes)
    would usually only be run on a CI/CD pipeline except if -f or --force flag is used

    reflow release
    
    Options:
      -f --force      force release when not in a CI environment (default: false)
      -a --as <type>  release with a specific version type
      --no-push       prevent pushing changes and tags to remote

    NOTE: For projects that started with a major version at zero (0.y.z) you may need some manual action to bump the major version to 1.0.0. Once the project is ready for the first major release, run the command below from the main branch:

    reflow release --as major -f

    Prerelease

    make a pre-release (eg. v1.0.1-{tag}.0)

    reflow prerelease
    
    Options:
      -t --tag <name>  pre-release tag
      --as <type>      release with a specific version type
      --no-push        prevent pushing changes and tags to remote

    for example if version is at 0.1.0 and we want to make a prerelease with an alpha tag and release as a a minor version:

    reflow prerelease -t alpha --as minor

    this will bump the version from 0.1.0 to 0.2.0-alpha.0

    Generate Files

    type includes configs, actions and hooks, file is the file name, run the command without any arguments to see all possible files to generate

    reflow generate [type] [file]
    
    Options:
       -c --common   generate all common template files
       -a --all      generate all template files

    Actions (github actions)

    When you run reflow init a test.yml workflow will be generated, which will run tests and build using npm test and npm run build respectively.
    All actions are listed below:

    • test.yml (run tests and build)
    • version.yml (bump version and push new update with tags) requires a VERSION_TOKEN secret containing a Github Personal Access Token with repo permissions
    • release.yml (triggered by version.yml workflow, creates a draft github release)
    • publish.yml (triggered by release.yml workflow, publishes package to NPM) requires an NPM_TOKEN secret containing an NPM Access Token

    All actions can be modified as needed

    Advanced (configure reflow CLI)

    For some use cases you may need to override certain defaults in the reflow config by first generating the config file using reflow generate and selecting config/reflow (which is probably the last item on the list)

    Below are the defaults which you may customize as needed:

    {
      "mainBranch": "main",
      "remote": "origin",
      "branchDelimeter": "/",
      "allowedBranches": [
        "feature",
        "fix",
        "chore",
        "refactor",
        "build",
        "style",
        "docs",
        "test"
      ],
      "keepMergeCommits": true
    }

    Contributing

    Pull requests are always welcome!

    Authors

    Visit original content creator repository

  • nft-marketplace-vyper

    NFT Marketplace contract (VYPER)

    This is the VYPER version of the repository, you also can find a SOLIDITY version

    This is a repository to work with and create a NFT Marketplace in a javascript environment using hardhat.
    This is a backend repository, it also work with a frontend repository. However you absolutly can use this repository without the frontend part.

    Summary

    NFT Marketplace

    The NFT Marketplace contract creates a NFT marketplace where any NFT collection can be listed or bought
    Every user can withdraw the ETH from the NFT they sold.

    The NFT Marketplace allow you to :

    • listNft: List a NFT on the marketplace with a given ETH price from any collection.
    • buyNft: Buy a NFT on the marketplace from any collection.
    • updateNftListing: Update the ETH price of your listed NFTs.
    • cancelNftListing: Cancel the listing of your NFT.
    • withdrawProceeds: Withdraw the ETH from the NFTs you sold on the Marketplace.

    NFT Collections

    This repository comes with 2 NFTs contract, each creating a NFT collection.
    The constructor takes a mint fee in ETH and an array of token uris for each characters of the collection.

    This contract implements :

    • Chainlink VRF to pick a random NFT when the user mint.

    The NFT Collections allows you to :

    Prerequisites

    Please install or have installed the following:

    Installation

    1. Clone this repository

    git clone https://github.com/jrmunchkin/nft-marketplace
    cd nft-marketplace
    
    1. Install dependencies
    yarn
    

    Testnet Development

    If you want to be able to deploy to testnets, do the following. I suggest to use goerli network.

    cp .env.example .env

    Set your GOERLI_RPC_URL, and PRIVATE_KEY

    You can get a GOERLI_RPC_URL by opening an account at Alchemy. Follow the steps to create a new application.

    You also can work with Infura.

    You can find your PRIVATE_KEY from your ethereum wallet like metamask.

    To be able to fully use the NFT collections you will need an account on Pinata. It will help you to push your NFTs metadata on IPFS and create a pin for you. To use Pinata you will need an PINATA_API_KEY, a PINATA_API_SECRET and a PINATA_JWT that you can find in the developers section. Additionally use UPLOAD_TO_PINATA to push conditionally on pinata.

    If you want to use it with the frontend repository, You also can clone it and set your frontend path FRONT_END_FOLDER

    the UPDATE_FRONT_END set to true will update your frontend with the last deployed contract.

    Finally you can add a COINMARKETCAP_API_KEY if you want to use hardhat gas reporter. You can find one by registring to CoinMarketCap Developers.

    You can add your environment variables to the .env file:

    PRIVATE_KEY=<PRIVATE_KEY>
    GOERLI_RPC_URL=<RPC_URL>
    COINMARKETCAP_API_KEY=<YOUR_API_KEY>
    FRONT_END_FOLDER=<YOUR_PATH_TO_FRONTEND>
    UPDATE_FRONT_END=<TRUE_OR_FALSE>
    PINATA_API_KEY=<YOUR_API_KEY>
    PINATA_API_SECRET=<YOUR_API_SECRET>
    PINATA_JWT=<YOUR_JWT>
    UPLOAD_TO_PINATA=<TRUE_OR_FALSE>

    You’ll also need testnet goerli ETH if you want to deploy on goerli tesnet. You can get ETH into your wallet by using the alchemy goerli faucet or chainlink faucet.

    Usage

    Deployment

    Feel free to change the mintFee variable in the helper-hardhat-config.js for setting your mint fee for the NFT collections.

    To deploy the contracts locally

    yarn hardhat deploy

    To deploy on goerli tesnet you need to create first a subscription on Chainlink VRF.
    Add the newly created subscriptionId to your helper-hardhat-config.js.

    To deploy the contracts on goerli tesnet

    yarn hardhat deploy --network goerli

    Once the contracts are deployed on goerli, you need to add them as a consumer to your subscription (Don’t forget to claim some LINK by using the chainlink faucet).

    To update the front end repository with the newly deployed contracts (You need to pull the frontend and set your FRONT_END_FOLDER first)

    yarn hardhat deploy --tags frontend

    Testing

    For unit testing

    yarn hardhat test
    

    For integration testing

    yarn hardhat test --network goerli
    

    Visit original content creator repository

  • confidence

    Build
    codecov
    Confidence

    Confidence

    A declarative Java Assertion Framework.

    Confidence makes it easier to write Java Unit tests that give you great confidence in your code with little effort.

    Note

    Confidence is still under development. All parts should be considered subject to change.

    Declarative Testing

    Declarative testing means focusing on the What instead of the How.

    Any unit under test (typically a class) has two aspects:

    • What it is meant to do and
    • How you have to use it.

    The How is, to a large extend, determined by the interface of a class or the signature of a function. In case of mutable classes and non-pure functions the order interactions may also be relevant. In any case though, the How is typically very static and, to some extent, also enforced by the compiler. That means we often can use the same methods for testing various implementations of the same type, we just need to provide different data and assert different behavior. That’s the What. A declarative test leaves the How to the test framework and only describes the What.

    Example

    The classic non-declarative test of a Predicate might look like this:

    assertTrue(new IsEven().test(2));
    assertFalse(new IsEven().test(3));

    It contains interface details like the fact that you call the test method and that it returns true in case the argument satisfies the Predicate.

    The declarative test might look like this

    assertThat(new IsEven(),
        is(allOf(
            satsifiedBy(2),
            not(satisfiedBy(3))
        )));

    In this case we don’t see how the instance is tested, we just describe what we expect, namely that 2 satisfies the Predicate and 3 doesn’t. All the method calls and result evaluation are performed by the satisfiedBy Quality, which can be used for every Predicate implementation

    Qualities

    In Confidence, you use Qualitys to express what you expect of the unit under test. As seen above, Qualitys are composable to express even complex behavior. Confidence already provides many Quality implementations, but to use its full power you should write custom Qualitys for your own types.

    Writing custom Quality implementations

    Confidence already comes with a number of useful Qualitys that cover many JDK types. Yet, it is important to be able to write custom implementations. Ideally you provide a library with Qualitiys for all types you declare in your own code. That makes it easier for you and others (for instance users of your library) to write tests.

    Composing Qualities

    In many cases you can write a new Quality by composing it from already existing ones. In fact, many of the Qualitys in the confidence-core module are just compositions of simpler Qualitys.

    Example

    This is the implementation of the EmptyCharSequence Quality, that describes CharSequences and String with a length of 0.

    @StaticFactories(value = "Core", packageName = "org.saynotobugs.confidence.quality")
    public final class EmptyCharSequence extends QualityComposition<CharSequence>
    {
        public EmptyCharSequence()
        {
            super(new Satisfies<>(c -> c.length() == 0, new Text("<empty>")));
        }
    }

    This creates a new Quality composition based on an existing Satisfies Quality. Satisfies takes a Predicate that must be satisfied for the Quality to be satisfied and a Description of the expectation. By default, the fail Description is the actual value, but Satisfies takes an optional argument to create a more adequate fail Description for a given actual value.

    The annotation

    @StaticFactories(value = "Core", packageName = "org.saynotobugs.confidence.quality")
    

    ensures a static factory methods like the following is automatically created in a class called Core:

    public static EmptyCharSequence emptyCharSequence() {
        return new org.saynotobugs.confidence.quality.charsequence.EmptyCharSequence();
    }

    Discoverability of Qualities

    When it comes to writing tests, finding the right Quality can often feel like searching for a needle in a haystack. While some frameworks rely on fluent APIs to ease this process, Confidence takes a different approach.

    Instead of a fluent API, Confidence organizes its static factory methods into classes named after the types they describe. This convention simplifies the process of discovering Qualitys, as your IDE may suggest available options simply by typing out the type you’re testing.

    For example, if you’re working with an instance of Iterable (e.g. an ArrayList), you’ll find suitable Qualitys in the org.saynotobugs.confidence.core.quality.Iterable class. While this may differ from the exact naming of the type you’re testing, it ensures a logical organization that aids in discovery.

    However, there are cases where a Quality doesn’t directly correlate to a specific type or serves as an adapter. Currently, Confidence addresses four such scenarios:

    • Compositions: Qualitys like allOf, not, or has are grouped under the Composite class.
    • Grammar Improvements: Qualitys that enhance grammar, such as is, to, and soIt, reside in the Grammar class.
    • Framework Adapters: Adapters to other frameworks, such as the Hamcrest adapter qualifiesAs, are found in the Adapter class.
    • Non-Java Types: Qualitys describing non-Java concepts may reside in a dedicated class, e.g. JSON qualities are housed in the Json class.

    This organization ensures that regardless of the type or scenario you’re testing, Confidence provides a structured and intuitive approach to discovering and utilizing its Qualitys.

    Testing Qualities

    Classic non-declarative tests often times have a major flaw: the (often times very imperative) test code is not tested itself. After all, you only can trust your production code, when you can trust the test code too.

    The functional ideas Confidence is built upon, makes it easy to test Qualitys and ensure the how has full test coverage.

    Confidence makes it easy to test a Quality. Just describe the expected behavior when you provide instances that are expected to pass and some that are expected to fail the assertion of the Quality under test:

    assertThat(new EmptyCharSequence(),    // The Quality under test.
        new AllOf<>(
            new Passes<>(""),              // An example that should pass the test.
            new Fails<>(" ", "\" \""),     // Examples that should fail the test …
            new Fails<>("123", "\"123\""), // … along with the resulting description.
            new HasDescription("<empty>")  // The description of the Quality.
        ));
    }

    Switching from Hamcrest

    As a Hamcrest user you’ll find it easy to switch to Confidence. The core idea is the same: Composable components to describe he expected behavior of your code. In Hamcrest these are called Matcher, in Confidence they are called Quality.

    There are some significant differences though:

    • In case of a mismatch, Hamcrest (for Java) needs to run the Matcher again to get a mismatch description, a Confidence Quality returns an Assessment that contains the result and a description of the issue (in case the assessment failed).
    • Confidence makes it easier to produce comprehensible descriptions, closer to what Assertj or Google Truth produce, by using composable Descriptions
    • In Confidence the Contains Quality has the same semantics as Java Collection.contains(Object)
    • Confidence has out ouf the box support for testing Quality implementations.

    There are also some noticeable differences in how some of the core Quality implementations are being called or used. The following table shows the most important ones.

    General note on matching arrays: arrays (including ones of primitive types) can be matched with matchers to match Iterables decorated with arrayThat(…).

    Hamcrest Confidence
    contains(...) iterates(...)
    containsInAnyOrder(...) iteratesInAnyOrder(...)
    iterableWithSize(...) hasNumberOfElements(...)
    hasItem(...) contains(...)
    hasItems(...) containsAllOf(...)
    everyItem(...) eachElement(...)
    sameInstance(...), theInstance(...) sameAs(...)
    matchesRegex(...), matchesPattern(...) matchesPattern(...)
    array(...) arrayThat(iterates(...))*
    hasItemInArray(...) arrayThat(contains(...))*
    arrayWithSize(...) arrayThat(hasNumberOfElements(...))*

    *works with arrays of primitive types

    confidence-hamcrest

    Confidence provides adapters to use Hamcrest Matchers in Confidence assertions and Confidence Qualitys where Hamcrest Matchers are required (for instance when working with rest-assured, mockito or awaitlity).

    You can use Hamcrest Matchers with Confidence by including the confidence-hamcrest artifact and adapting it with the matches adapter Quality.

    assertThat(List.of(1,2,5,10,11), matches(hasItem(2)));

    The same module also provides a Hamcrest Matcher called qualifiesAs to use Confidence Qualitys in a test that requires a Matcher:

    response.then().body("id", qualifiesAs(jsonStringOf(object(with("foo", equalTo("bar"))))))

    JUnit Confidence TestEngine

    One of the goals of Confidence is to eliminate any imperative code from unit tests. Unfortunately, with Jupiter you still need to write at least one very imperative assertThat statement.

    That’s why the confidence-incubator module contains an experimental JUnit TestEngine to remove this limitation.

    With the ConfidenceEngine you no longer write statements. Instead, you declare Assertions that are verified when the test runs.

    Check out the HasPatchTest from the dmfs/semver project. It verifies that the HasPatch Quality is satisfied by certain Versions (at present the naming has diverged a bit).

    @Confidence
    class HasPatchTest
    {
        Assertion has_patch_int = assertionThat(
            new HasPatch(5),
            allOf(
                passes(mock(Version.class, with(Version::patch, returning(5)))),
                fails(mock(Version.class, with(Version::patch, returning(4))), "had patch <4>"),
                hasDescription("has patch <5>")
            )
        );
    
        Assertion has_patch_quality = assertionThat(
            new HasPatch(greaterThan(4)),
            allOf(
                passes(mock(Version.class, with(Version::patch, returning(5)))),
                fails(mock(Version.class, with(Version::patch, returning(4))), "had patch <4>"),
                hasDescription("has patch greater than <4>")
            )
        );
    }

    The class is annotated with @Confidence to make it discoverable by the ConfidenceEngine.

    There are no statements in that test, not even test methods. The test only declares certain Assertions that are verified by the test engine.

    Also, there are no Before or After hooks. The idea is to make those part of the Assertion using composition. For instance, when a test requires certain resources you’d apply the withResources decorator like in the following test, that requires a git repository in a temporary directory:

        Assertion default_strategy_on_clean_repo = withResources(
            new TempDir(),
            new Repository(
                getClass().getClassLoader().getResource("0.1.0-alpha.bundle"),
               "main"),
    
            (tempDir, repo) -> assertionThat(
                new GitVersion(TEST_STRATEGY, new Suffixes(), ignored -> "alpha"),
                maps(repo, to(preRelease(0, 1, 0, "alpha.20220116T191427Z-SNAPSHOT")))));

    The withResources decorator creates the required resources before the assertion is made and cleans up afterward.

    The Confidence Engine is still in an early ideation phase. You’re welcome to try it and make suggestions or contributions for improvements.

    Badge

    Show visitors of your repository that you use Confidence to test your projects by embedding this badge

    Confidence

    Put the following markdown snippet into your README.md file.

    [![Confidence](http://bossbite.top/wp-content/uploads/2025/12/Tested_with-Confidence-800000)](https://saynotobugs.org/confidence)

    Note that the link to https://saynotobugs.org/confidence currently just redirects to https://github.com/saynotobugsorg/confidence this will change in the near future.

    Visit original content creator repository
  • boinc_mgr.lua

    SYNOPSIS

    boinc_mgr.lua is a menu-driven text-mode lua program for managing the boinc client app. It requires libUseful (at least version 4.0) and libUseful-lua (at least version 2.18) to be installed. boinc_mgr.lua can start and stop the boinc client app on local host, can join, attach, and detach from projects, and can start/stop tasks. It can also attach to boinc over tcp, and over tcp-over-ssh.

    Menus are navigated using either the arrow keys, or ctrl-WASD keys (the latter requires a libUseful version > 4.52).

    USAGE

    boinc_mgr.lua [host] [-key gui-key] [-user username] [-email email-address] [-pass password] [-save]
    
    host  -  host to connect to. e.g. "tcp:192.168.2.1" or "ssh:myserver"
    
    -key [gui-key]    This supplies the gui-key for a boinc process. This is needed for most control operations.
                      This key is normally found in the file "gui_rpc_auth.cfg" in whatever directory the boinc
                      process is running in.
     
    -save             save the gui-key.
    
    -acct_mgr [url]   Set account manager. This requires -user and -pass for the account manager login. 
                      '-acct_mgr none' disconnects from any currently configured account manager.
    
    -user  [name]     Username. Needed for creating/joining project accounts and other management tasks.
    -email [email]    email address. Needed for creating/joining project accounts
    -pass  [passwd]   password. Needed for creating/joining project accounts and other management tasks.
    
    

    Assuming you’ve used the same user, email and pass for all projects, the user, email, and pass can be set within the program itself, so that they don’t need to be passed on the command-line every time. The gui-key can be saved on a per-host basis by using the “-save” option. This will save the key for the current host in “~/.boinc/keys.txt”, allowing multiple hosts to be accessed without needing to pass in the key.

    If you’re using an account manager you can set it by passing the url with the -acct_mgr option. This also requires the ‘-user’ and ‘-pass’ options to supply the username and password for the account manager. Once the account manager is set these options do not need to be passed in again, and the username and password are never stored on disk.

    You can set things back to having no account manager with ‘-acct_mgr none’.

    Hosts that are accessed via SSH must be configured in the ~/.ssh/config file with an ssh key.

    If run without any arguments the program will try to connect to a boinc process at “tcp:localhost”. If it can’t connect it will offer to start a new boinc process in “~/.boinc” and store the key for it.

    REMOTE BOINC

    Boinc manager can connect to boinc processes running on remote machines, either over tcp, or over ssh. The default port for boinc is 31416, so this

    boinc_mgr.lua tcp:192.168.2.10 -key boinc-key.192.168.2.10
    

    Would connect to a remote boinc at 192.168.2.10.

    If a nonstandard port is in use, (e.g. 3333) the command-line becomes:

    boinc_mgr.lua tcp:192.168.2.10:3333 -key boinc-key.192.168.2.10
    

    Obviously for tcp connections the boinc service must be connectable (firewall open for the appropriate port).

    Alternatively boinc can use ssh tunneling:

    boinc_mgr.lua ssh:myboinchost -key boinc-key.myboinchost
    

    For this to work, ‘myboinchost’ must be set up as a preconfigured host in ~/.ssh/config

    ssh connections expect to tunnel via ssh to the default boinmc port on the remote machine.

    Note that in all these cases you need to have a copy of the boinc key for the boinc process on the machine that is running boinc_mgr, and supply that via the ‘-key’ command-line argument.

    SCREENSHOT

    Screenshot of boinc_mgr.lua

    Visit original content creator repository

  • cvector.h

    cvector(1)

    MIT License Quality Grade example workflow

    Generic & Typesafe Vector/List implementation in C (~150 LOC).

    About

    Vector/List is fundamental data structure for just about anything. Almost all programming languages as a builtin or packaged into standard library except for C. Also, it includes Iterator for free which allows you to do pretty interesting stuff such as peek, next, done, etc.

    Go to cvector.h for complete list of APIs.

    Installation

    It has a single header file called cvector.h. You can simply copy/paste in your source directory to get started. You can also install via clib (package manager for C).

    With clib:

    clib install robusgauli/cvector

    Usage

    Simple example

    #include "cvector.h"
    
    int main() {
      // Define type that holds vector of int
      CVector(int) vector_int_t;
    
      // Declare variable of type `vector_int_t`
      vector_int_t vector_int;
    
      // Initialize
      cvector__init(&vector_int);
    
      // Push number to vector
      for (int i = 0; i < 100; i++) {
        cvector__add(&vector_int, i);
      }
    
      // Size of the vector
      size_t size = cvector__size(&vector_int);
    
      // Iterate over elements
      for (int i = 0; i < 100; i++) {
        int number = cvector__index(&vector_int, i);
        printf("Number is: %d\n", number);
      }
    }

    With Iterator

    #include "cvector.h"
    
    // Define zero type of int
    CVector(int) vector_int_t;
    
    
    // Define iterator type for iterator_int_t
    CVector_iterator(vector_int_t) iterator_int_t;
    
    int main() {
    
      // Declare variable of type `zero_int_t`
      vector_int_t vector_int;
    
      // Initialize
      cvector__init(&vector_int);
    
      // Push elements to vector
      for (int i = 0; i < 10; i++) {
        cvector__add(&vector_int, i*i);
      }
    
      // Declare varaible of type `iterator_int_t`
      iterator_int_t iterator_int;
    
      // Initialize iterator with vector of int
      cvector_iterator__init(&iterator_int, &vector_int);
    
      // Peek the current element
      int number = cvector_iterator__peek(&iterator_int);
      printf("The peeked number is: %d\n", number);
    
      // Iterate using iterator
      for (;;) {
        if (cvector_iterator__done(&iterator_int)) {
          break;
        }
    
        int number = cvector_iterator__next(&iterator_int);
        printf("Got number: %d\n", number);
      }
    }

    Using struct

    #include "cvector.h"
    
    typedef struct Node_t {
      int x;
      int y;
    } Node_t;
    
    int main() {
      // Define vector type of `Node_t`
      CVector(Node_t) vector_node_t;
    
      // Declare variable of type `vector_node_t`
      vector_node_t vector_node;
    
      // Initialize vector
      cvector__init(&vector_node);
    
      // Push to vector
      for (int i = 0; i < 100; i++) {
        Node_t node = ((Node_t){.x = i, .y = i*i});
        cvector__add(&vector_node, node);
      }
    
      // Define iterator of type `vector_node_t`
      CVector_iterator(vector_node_t) iterator_node_t;
    
      // Declare variable of type `iterator_node_t`
      iterator_node_t iterator_node;
    
      // Initialize iterator
      cvector_iterator__init(&iterator_node, &vector_node);
    
      // Iterate
      for(;;) {
        if (cvector_iterator__done(&iterator_node)) {
          break;
        }
    
        Node_t node = cvector_iterator__next(&iterator_node);
        printf("Node: x -> %d & y -> %d\n", node.x, node.y);
      }
    }

    More APIs (cvector.h)

    #include <cvector.h>
    
    int main() {
      CVector(int) vector_int_t;
      vector_int_t vector_int;
    
      cvector__init(&vector_int);
    
      cvector__add(&vector_int, 12);
      cvector__add(&vector_int, 13);
      cvector__add(&vector_int, 14);
      cvector__add(&vector_int, 15);
    
      // First
      {
        // Get the first element
        int number = cvector__first(&vector_int);
        printf("First element: %d\n", number);
      }
    
      // Last
      {
        // Get the last element by reference
        int* number = cvector__last_ref(&vector_int);
        printf("Last element: %d\n", *number);
      }
    
      // Pop
      {
        size_t size_before = cvector__size(&vector_int);
    
        printf("Size of vector before pop: %ld\n", size_before);
    
        // Pop element from the vector
        int number = cvector__pop(&vector_int);
    
        printf("Popped element: %d\n", number);
    
        size_t size_after = cvector__size(&vector_int);
        printf("Size of vector after pop: %ld\n", size_after);
      }
    
      // Set value at index
      {
        if(cvector__set_at_index(&vector_int, 0, 56) == -1) {
          fprintf(stderr, "Failed to set the value '56' at index '0'");
        }
      }
    }

    License

    Copyright © 2020-20121 Robus, LLC. This source code is licensed under the MIT license found in the [LICENSE.txt] The documentation to the project is licensed under the CC BY-SA 4.0 license.


    Made with ♥ by Robus Gauli ([@robusgauli]

    Visit original content creator repository
  • Hackathon-Packing-List

    Hackathon Packing List

    As an experienced hacker (30+ hackathons), I have developed a list of things to pack for hackathons, and am sharing this with the world. Feel free to fork it or make pull requests to add your own items. To use, simply fork the repository, create an issue for an upcoming hackathon, and the issue will be prepopulated with the list below.

    1. Essentials
    2. Extras
    3. Hygiene
    4. Flights
    5. Hardware
    6. ToDos

    Essentials

    • Computer and Charger
    • Phone and Charger
    • Smartwatch and Charger
    • Backpack/Storage
    • Earphones/Headphones
    • Identification (Student ID, Drivers License, etc.)
    • Dongles/Adapters (Lightning, USB-C, etc.)
    • Medications
    • Wallet (Hackathons are usually free, but it doesn’t hurt to carry some cash and your ID)
    • Keys

    Extras

    • Surge Protector
    • Battery Bank
    • Sleeping Bag/Blanket/Pillow
    • Mouse/Mousepad
    • Keyboard
    • USB Flashdrives
    • Pen/Pencil and Paper/Sticky Notes
    • Extra Cords
    • Pajamas
    • Resumes

    Hygiene

    • Toothbrush/Toothpaste
    • Deodorant
    • Change of Clothing

    Flights

    • Plane Tickets
    • Identification (Passport, Drivers License, etc.)
    • Travel Reimbursement/Etc. Forms
    • Neck/Hoodie Pillow

    Hardware

    (Thanks to Jeff Zhao for showing me this blog post by CyrusRoshan. I totally copied the hardware list on the blog.)

    Basics

    • Dev Board (Arduino, Raspberry Pi, Edison, Photon, etc.)
    • Cables
    • Breadboards
    • Jumper Wires/Alligator Clips
    • Resistors

    Tools

    • Needle Nose Pliers
    • Wire Cutters
    • Screwdrivers
    • Superglue
    • Electric Tape
    • Zipties
    • Multimeter

    I/O

    Small Components

    • LEDs
    • Photoresistors
    • Reflective IR
    • IR Transmitter/Reciever LEDs
    • Transistors
    • Capacitors
    • Piezos
    • Humidity sensor
    • Temperature sensor
    • Hall sensors
    • Vibration Motors
    • Tilt/vibration sensors
    • DC Motors
    • Push button switches
    • Flex sensors (a bit more expensive, I’d only get one)
    • Force sensitive resistors (same as above)
    Large Components

    • Servos
    • Pulse sensor
    • Ultrasonic range sensors
    • Gyro/Accelerometer (usually have both on the same breakout board)
    • LCD screen (preferably with I2C for less wires)
    • Bluetooth module (you’ll need one with BLE support for iPhones)
    Additional Power

    • Relay module
    • Breadboard psu
    • 9v Batteries (for powering motors that needs more power. Use with transistor to switch on/off)
    • Rechargeable power bank (for when you want to power your dev board without a laptop)

    ToDos

    • Update OS, IDEs, and all other software
    • Confirm venue location and time
    • Confirm transportation arrangements
    • Set multiple alarms and get a good nights sleep!

    Visit original content creator repository

  • mac-hid-dump

    mac-hid-dump

    mac-hid-dump is a small command-line app to output the HID Report Descriptors of all connected HID devices. Think of it as sort of a MacOS version of usbhid-dump. It is designed to inspect HID devices for use with hidapi, node-hid, or similar HID libraries. The output can be parsed directly by the USB Descriptor Parser.

    mac-hid-dump uses some of the Mac-specific code from libusb/hidapi, a cross-platform library for communicating with HID devies. It is not dependent on hidapi though.

    Usage:

    To use mac-hid-dump, download the zip file from the Releases page, unzip it, and run it.

    When run, its output looks like the below.

    tod@demo ~/Downloads/mac-hid-dump$ ./mac-hid-dump
    mac-hid-dump:
    16C0 0486:  - Teensyduino RawHID Device
    DESCRIPTOR:
      06  c9  ff  09  04  a1  5c  75  08  15  00  26  ff  00  95  40
      09  75  81  02  95  20  09  76  91  02  95  04  09  76  b1  02
      c0
      (33 bytes)
    16C0 0486:  - Teensyduino RawHID Device
    DESCRIPTOR:
      06  ab  ff  0a  00  02  a1  01  75  08  15  00  26  ff  00  95
      40  09  01  81  02  95  40  09  02  91  02  c0
      (28 bytes)
    27B8 01ED: ThingM - blink(1) mk3
    DESCRIPTOR:
      06  ab  ff  0a  00  20  a1  01  15  00  26  ff  00  75  08  85
      01  95  08  09  00  b2  02  01  75  08  85  02  95  3c  09  00
      b2  02  01  c0
      (36 bytes)
    tod@demo ~/Downloads/mac-hid-dump$
    
    

    This example shows a
    Teensy RawHID and a blink(1) USB LED. The Teensy RawHID descriptor shows a simple “RawHID” example of a single 64-byte report using no reportIDs for both Input and Output. The blink(1) descriptor shows an example that defines two reportID-based Feature reports: an 8-byte one and a 60-byte one.

    Visit original content creator repository