Skip to content

Instantly share code, notes, and snippets.

@alcedo
alcedo / aes_gcm.go
Created December 20, 2023 15:49
Golang AES GCM Encrypt String and File example
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"io"
"io/ioutil"
"log"
"os"
@alcedo
alcedo / Ethernaut - Q1.md
Last active October 31, 2023 16:09
ethernauts notes

Question 1 - Logic / Bad coding Flaws

you can use this to call the contribute method:

contract.methods["contribute()"].sendTransaction({value: 2});

or

sendTransaction({ from: "0x111" , to: instance, value:1, data: web3.eth.abi.encodeFunctionSignature('contribute()')

@alcedo
alcedo / slack_delete.rb
Last active June 21, 2016 20:37 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
# tokens can be obtained from https://api.slack.com/docs/oauth-test-tokens
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
@alcedo
alcedo / rails_txn_rollback_spec.rb
Last active November 21, 2015 12:04
Rails Transaction Demonstration
require 'spec_helper'
describe 'Rails Transaction Demonstration' do
it 'Should rollback due to any exception raised' do
expect {
ActiveRecord::Base.transaction do
NotificationHistory.create!(transporter: 'should not see this')
@alcedo
alcedo / jsonMock.objc
Created June 21, 2015 22:08
sample code showing how to use mock JSON response
NSString *mockResponse = @"{\
\"account_balance\": \"304.34\",\
\"bank_account_number\": \"03168943233\",\
\"bank_account_type\": \"POSB\",\
}";
NSError *jsonError;
NSData *objectData = [mockResponse dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData
options:NSJSONReadingMutableContainers
[
{
"coordinates": null,
"truncated": false,
"created_at": "Tue Aug 28 21:16:23 +0000 2012",
"favorited": false,
"id_str": "240558470661799936",
"in_reply_to_user_id_str": null,
"entities": {
"urls": [
@alcedo
alcedo / Rt.json
Created May 6, 2015 06:56
Rotten tomato API
{
"movies": [
{
"id": "771313962",
"title": "Avengers: Age of Ultron",
"year": 2015,
"mpaa_rating": "PG-13",
"runtime": 141,
"critics_consensus": "",
"release_dates": {
//
// PhotoTableViewCell.swift
// codepath_wk1e1
//
// Created by Victor Liew on 5/3/15.
// Copyright (c) 2015 alcedo. All rights reserved.
//
import UIKit
@alcedo
alcedo / devise token auth notes
Created October 25, 2014 23:44
A list of Token authentication tutorials on rails using devise
https://gist.github.com/josevalim/fb706b1e933ef01e4fb6
https://gist.github.com/gonzalo-bulnes/7659739
https://github.com/plataformatec/devise/issues/2739
https://gist.github.com/danielgatis/5666941
http://stackoverflow.com/questions/20319961/restful-login-with-devise-rails-4
http://chasseurmic.github.io/chasseurmic/blog/2013/02/13/restful-api-authentication/
http://lucatironi.github.io/tutorial/2013/05/05/ruby_rails_rubymotion_ios_app_authentication_devise_tutorial_part_one/
http://blog.codebykat.com/2012/07/23/remote-api-authentication-with-rails-3-using-activeresource-and-devise/
http://codedecoder.wordpress.com/2013/01/08/devise-login-with-authentication_token/