Skip to content

Instantly share code, notes, and snippets.

View aramkoukia's full-sized avatar
🏠
Working from home

Aram Koukia aramkoukia

🏠
Working from home
View GitHub Profile
@aramkoukia
aramkoukia / smart-contract-info-by-transaction-hash.cs
Created January 24, 2017 17:47
Get Smart Contract Information using the transaction hash
var getAddress = "./geth.ipc";
var web3 = new Web3(ipcClient);
var reciept = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash);
// If reciept is null it means the Contract creation transaction is not minded yet.
if (reciept != null)
contractAddress = reciept.ContractAddress;
@aramkoukia
aramkoukia / nethereum-smart-contract-deploy.cs
Created January 24, 2017 17:42
Deploy Smart Contract using Nethereum
var abi = @"[{""constant"":false,""inputs"":[],""name"":""destinationAddressRouteFound"",""outputs"":[{""name"......................";
var byteCode = "606060405260405160608061027e83395060c06040525160805160a05160008054600160a060020a03199081166c0100..............................";
var publicKey = "0x.....";
var gas = new Nethereum.Hex.HexTypes.HexBigInteger(300000);
var balance = new Nethereum.Hex.HexTypes.HexBigInteger(120);
var transactionHash = await web3.Eth.DeployContract.SendRequestAsync(abi, byteCode, publicKey, gas, balance);
@aramkoukia
aramkoukia / unlock-ethereum-account.cs
Created January 24, 2017 17:37
Unlock Account Using Nethereum
// You need to have the geth running while running this code. command: c:\geth\>geth --testnet
var string _getAddress = "./geth.ipc";
var ipcClient = new Nethereum.JsonRpc.IpcClient.IpcClient(_getAddress);
var web3 = new Web3(ipcClient);
// this will leave the account unlucked for 2 minutes
var Nethereum.Hex.HexTypes.HexBigInteger accountUnlockTime = new Nethereum.Hex.HexTypes.HexBigInteger(120);
var accountPublicKey = "ACCOUNT_PUBLIC_KEY";
@aramkoukia
aramkoukia / payout-sample-solidity-smart-contract.sol
Created January 17, 2017 17:36
payout sample solidity smart contract
contract Payout {
address Victor;
address Jim;
address Kieren;
mapping (address => uint) ownershipDistribution;
function Setup() {
Victor = 0xaabb;
Jim = 0xccdd;
@aramkoukia
aramkoukia / angular-custom-pipe-module.ts
Created December 27, 2016 18:05
angular custom pipe module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MyComponent } from './my.component';
import { MyPipe } from './my.pipe';
@NgModule({
imports: [
BrowserModule,
],
@aramkoukia
aramkoukia / angular-custom-pipe-component.ts
Created December 27, 2016 18:04
angular custom pipe component
import { Component } from '@angular/core';
@Component({
selector: 'my-component',
template: `{{ value | myPipe }}`
})
export class MyComponent {
public value:any;
@aramkoukia
aramkoukia / angular-custom-pipe.ts
Created December 27, 2016 18:03
angular custom pipes
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'myPipe'})
export class MyPipe implements PipeTransform {
transform(value:any, args?: any):string {
let transformedValue = value; // implement your transformation logic here
return transformedValue;
}
}
@aramkoukia
aramkoukia / angular-built-in-pipe.html
Created December 27, 2016 17:58
angular built-in pipe html
<div>
<h1>Welcome back {{fName | uppercase}} {{lName | lowercase}}</h1>
<p>
On {reservationMade | date} at {reservationMade | date:'shortTime'} you
reserved room 205 for {reservationDate | date} for a total cost of
{cost | currency}.
</p>
</div>
@aramkoukia
aramkoukia / angular-built-in-pipe.ts
Created December 27, 2016 17:56
angular built-in pipe sample
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'hotel-reservation',
templateUrl: './hotel-reservation.template.html'
})
export class HotelReservationComponent {
public fName: string = 'Joe';
public lName: string = 'SCHMO';
@aramkoukia
aramkoukia / Filling NULL values with Preceding Non-NULL values - Option 2.sql
Created December 22, 2016 18:15
Filling NULL values with Preceding Non-NULL values - Option 2
-- First of all I'll just put the data from my main table into a temp table
-- just to make sure i am not destroying the actual data if something went wrong.
SELECT * INTO #Temp FROM ImportedSales;
;With CTE As
(
SELECT ProductName , Id , COUNT(ProductName)
OVER(ORDER BY Id ROWS UNBOUNDED PRECEDING) As MyGroup FROM #Temp ), GetProduct AS (
SELECT [ProductName] , First_Value(ProductName)
OVER(PARTITION BY MyGroup
ORDER BY Id ROWS UNBOUNDED PRECEDING