Skip to content

Instantly share code, notes, and snippets.

[
{
"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 / 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
@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 / 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 / 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 / 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"