Skip to content

Instantly share code, notes, and snippets.

View swapnilraj's full-sized avatar

Swapnil Raj swapnilraj

View GitHub Profile
%lang starknet
from starkware.cairo.common.alloc import alloc
from starkware.cairo.common.cairo_builtins import BitwiseBuiltin
from starkware.cairo.common.cairo_keccak.keccak import keccak_uint256s, finalize_keccak, keccak_uint256s_bigend
rom starkware.cairo.common.math import split_felt
from starkware.cairo.common.math_cmp import is_le_felt
from starkware.cairo.common.uint256 import Uint256, uint256_shl, uint256_add
func felt_to_uint256{range_check_ptr}(x) -> (x_ : Uint256):
contract test {
function f(bool cond) public returns (uint) {
uint8 x = 0xcd;
uint16 y = 0xabab;
return cond ? x : y;
}
}
// ====
// compileToEwasm: also
// compileViaYul: also
@swapnilraj
swapnilraj / addmod_mulmod.sol
Last active January 19, 2022 17:57
Solidity Semantic Tests
contract C {
function test() public returns (uint256) {
// Note that this only works because computation on literals is done using
// unbounded integers.
if ((2**255 + 2**255) % 7 != addmod(2**255, 2**255, 7)) return 1;
if ((2**255 + 2**255) % 7 != addmod(2**255, 2**255, 7)) return 2;
return 0;
}
}
@swapnilraj
swapnilraj / Privacy Policy
Created February 4, 2019 12:40
Gloinebot - Privacy Policy
Privacy Policy
Effective date: February 04, 2019
Gloinebot ("us", "we", or "our") operates the Gloinebot mobile application (the "Service").
This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data. Our Privacy Policy for Gloinebot is created with the help of the Free Privacy Policy website.

Description

Motivation

We have decided to add bug reporting on the client using bugsnag, but we need to filter the reporting based on if the bug occurred on a music video or not. If we don't filter the bug reporting there would be too many notifications for bugs which are not in the project's scope.

To add filtering we need to decide if a video is a music video or not; since

Description

This change is a part of a bigger module and change relating to detecting music videos based on certain heuristics. This module detects if a video is a music video by checking for the verified artist icon next to the channel name.

YouTube channels that are recognized as music channels get a verified artist icon next to their channel name, this works in a similar way where popular YouTube channels get a verified icon next to their channel name.

@swapnilraj
swapnilraj / Lyricist - Add unit tests.md
Last active December 31, 2018 13:48
Document describing an approach to add unit tests to the project.

Description

As stated in our discussion while version 3.0.0 was being released we need to add tests to the project for several reasons, one of them being to easily verify new changes and make sure they don't break the project. The tests will also help keep track of the edge cases for future reference. This document is concerned only with unit tests but we will work in the future to add e2e testing.

Approach

@swapnilraj
swapnilraj / Lyricist - Fix title parser for - separator.md
Last active December 31, 2018 15:55
Lyricist = Proposal for fixing issue 11

Title extraction fix

This fix is addressing the issue #11, to explain the issue in detail; the current extraction is done using regular expressions and the current expression used is /(.*)(\||\/\/\/|-|:)(.*)(\s-\sYouTube)$/. The issue with this expression is the eager nature of the regex engine where it tries to capture the biggest expression possible.

This document is also an attempt at documenting the rather big regular

Brief

With the new changes coming in the MutationObserver branch; we discovered the title of the Youbube page is always the same as the title of the page and instead of doing an expensive call to the document with a query selector for the title of the video which is a nested DOM element we can use the document title.

The MutationObserver branch also makes all the lyric logic depend on the change in the title of the web-page; coupled with this change there is a nice

@swapnilraj
swapnilraj / bubba.bf
Last active December 7, 2018 23:36
bubba-brainfuck
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++
<<
[b.> u.> n> c[>+ <<<<.>>> -] > [-<+>]<+ <<<b..-.+ >>n. <<]