Skip to content

Instantly share code, notes, and snippets.

@tzmfreedom
tzmfreedom / encdec_apex
Created June 7, 2016 01:33
Encryption/Decription for apex
Blob cryptoKey = Crypto.generateAesKey(128);
Blob iv = Blob.valueOf('0123456789012345');
System.debug(EncodingUtil.base64encode(cryptoKey));
Blob data = Blob.valueOf('TestTest');
Blob encryptedData = Crypto.encrypt('AES128', cryptoKey, iv, data);
System.debug(EncodingUtil.base64encode(encryptedData));
//Blob decryptedData = Crypto.decrypt('AES128', cryptoKey, encryptedData);
//System.debug(decryptedData.toString());
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
loginUrl : 'https://login.salesforce.com'
});
conn.login("{username}", "{password}", function(err, userInfo) {
conn.sobject('hoge__c')
.find({})
.destroy(function(err, rets) {
if (err) { return console.error(err); }
console.log(rets);
cd C:\Users\hoge\vagrant
vagrant up
net use Z: \\192.168.33.10\Share /user:vagrant vagrant
import json
import psycopg2
import psycopg2.extras
import random
SETTINGS_JSON = 'settings.json'
RANDOM_SOURCE_STR = 'abcdefghijklmnopqrstuvwxyz0123456789'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt
import json
host = 'std1.mqtt.shiguredo.jp'
port = 8883
#port = 1883
req_topic = '{request_topic}'
package main
import (
"fmt"
"net"
"os"
"bufio"
"io"
"os/exec"
)
@tzmfreedom
tzmfreedom / vsz.c
Created November 2, 2016 03:16
Difference between VSZ(VIRT) and RSS(RES).
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <malloc/malloc.h>
int main(void)
{
char *buf = NULL;
//暗号化
private static final String cryptoKey = '{base 64 encoded key}';
public static String encryptedData(String s) {
Blob encryptedData = Crypto.encryptWithManagedIV('AES256', EncodingUtil.base64Decode(cryptoKey), Blob.valueOf(s));
System.debug(encryptedData);
System.debug(EncodingUtil.base64Encode(encryptedData));
String data = EncodingUtil.convertToHex(encryptedData);
String half1 = data.substring(0, data.length()/2);
String half2 = data.substring(data.length()/2, data.length());
# frozen_string_literal: true
source "https://rubygems.org"
# gem "rails"
gem "faraday"
@tzmfreedom
tzmfreedom / mysql-playbook.yml
Last active August 18, 2017 13:41
ansible playbook for mysql
---
- hosts: db_servers
become: yes
user: vagrant
vars:
- mysql_root_password: password
tasks:
- name: install rpm repository
yum: name=https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm state=present