Skip to content

Instantly share code, notes, and snippets.

View simanacci's full-sized avatar
💭
😷

simanacci

💭
😷
View GitHub Profile
pub async fn message<T>(
redis: &redis::Client,
sms: T,
gadget: Option<Uuid>,
uuid: Uuid,
) -> Result<Message, CustomError>
where
T: AsRef<str> + ToString,
{
if !helper::index_exists(redis, common::index::MESSAGES).await {
#[actix_web::test]
async fn units() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info");
std::env::set_var("RUST_BACKTRACE", "1");
dotenv::dotenv().ok();
let ctx = TestContext::new();
let meter = general::M1;
let gadget = fixtures::gadget(&ctx.client, meter, Uuid::new_v4()).await?;
@simanacci
simanacci / gist:4ce05a4a03d0b34a3db22423aec2a24c
Created February 3, 2024 08:39
Permission denied (publickey)
Run fifsky/ssh-action@master
with:
host: 65.123.123.133
user: sammy
key: ***
port: 22
command: cd ~
export SECRET=*** REDISRS_SERVER_TYPE=unix
docker-compose down
docker-compose pull
@simanacci
simanacci / wiremock.rs
Last active December 26, 2022 19:18
Mock HN API Request
// The test
let body = format!(
r#"
{{
"about" : "This is a test {}",
"created" : 1173923446,
"delay" : 0,
"id" : {},
"karma" : 2937,
"submitted" : [ 8265435, 8168423, 4289 ]
@simanacci
simanacci / curl.md
Created November 10, 2022 16:39 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

<html>
<body class="container">
<header>
<link href="/static/test.css" rel="stylesheet" type="text/css">
</header>
<main class="main">
<img id="profile-photo" src="https://test.s3.amazonaws.com/profile_photo/test.jpg" alt="Politician Profile Photo" >
</main>
</body>
</html>
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@simanacci
simanacci / mock_object.py
Created July 4, 2021 13:01 — forked from peterldowns/mock_object.py
Simple way of creating Mock objects from nested dictionaries.
import mock
def mock_object(data=None):
result = mock.MagicMock()
for key, value in data.iteritems():
if isinstance(value, dict):
result.configure_mock(**{
key: mock_object(value),
})
else:
result.configure_mock(**{
socket.on('notification-message', function(msg) {
var targetContainer = document.getElementById('notification-count');
console.log(targetContainer);
{% if request.endpoint == 'dash.notification' %}
var nextNotificationButton = document.getElementById('next-unread-notification');
var nextNotificationFooter = document.getElementById('notification-footer');
{% endif %}
if (msg.count != 0) {
targetContainer.classList.add("notification-count");
targetContainer.innerHTML = msg.count;
def generate_password_reset_token(self, expires_in=3600):
s = URLSafeTimedSerializer(current_app.config['SECRET_KEY'], expires_in)
return s.dumps(self.email, salt='password-recovery')
@staticmethod
def reset_password(token, new_password):
s = URLSafeTimedSerializer(current_app.config['SECRET_KEY'])
try:
email = s.loads(token, max_age=3600, salt='password-recovery')
except SignatureExpired: