Skip to content

Instantly share code, notes, and snippets.

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

Rodrigo Silveira RodrigoMattosoSilveira

🏠
Working from home
  • Madrone Software Technologies
  • Priest River, ID USA
View GitHub Profile
@RodrigoMattosoSilveira
RodrigoMattosoSilveira / gist:4664d600707ec41947e083e1e24b20a9
Last active June 9, 2024 21:52
Execute SQL statements from a file
Execute SQL statements from a file
Suppose we have a file named commands.txtin the c:\sqlite\folder with the following content:
```
SELECT albumid, title
FROM albums
ORDER BY title
LIMIT 10;
// GO: Convert a string to JSON
// Input: string
// Output:JSON if OK, nil otherwise
//
func stringToJSON (sourceString string) []byte {
var obj map[string]interface{}
err := json.Unmarshal([]byte(sourceString), &obj)
if err != nil {
fmt.Println(err)
return nil
@RodrigoMattosoSilveira
RodrigoMattosoSilveira / gist:ca553c6a53ef800d5f5416aaaae7bd69
Last active June 12, 2024 00:32
Convert GO: Convert a structure to a string
// GO: Convert a structure to a string
// Input: interface{}
// Output: (string, nil) if OK, ("", error) otherwise
//
func structToString (sourceStruct interface{}) (string, error) {
sourceJson, error := json.Marshal(sourceStruct)
if error != nil {
return "", error
}
return string(sourceJson), nil
/*
* *****************************************************************************
* GIST used to configure a typed React Redux component
* https://redux.js.org/recipes/usage-with-typescript/#usage-with-typescript
* *****************************************************************************
*/
// Comment out if not used
// interface OwnProps {
// }