Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
<div id="apiusers_list" _="on htmx:beforeSwap call disposeTooltip() on htmx:afterSwap call handleTableDomUpdated()"
class="content-block overflow-hidden">
{% include 'drafu/partial/_list_apiusers.html' %}
</div>
<div id="modal_container" _="on htmx:afterSwap call handleModalDomUpdated()"></div>
<form hx-post="{% url 'drafu:apiuser-list' %}" hx-target="#apiusers_list"
_="on htmx:responseError call swapBodyError()">
document.querySelector('.btn-create').addEventListener('click', function (e) {
getModalContent(e, this);
});
// test
var edit_modal_btn_list = document.querySelectorAll('.btn-edit');
edit_modal_btn_list.forEach(function (edit_btn, index) {
edit_btn.addEventListener('click', function (e) {
git rm --cached <file>
poetry run plum manage shell_plus
u = Member.objects.get(email='[email protected]')
u.set_password("123")
u.save()
export function recursiveFind(array, key, value) {
var o;
array.some(function iter(a) {
if (a[key] === value) {
o = a;
return true;
}
return Array.isArray(a.children) && a.children.some(iter);
});
return o;
@cyberfly
cyberfly / form.js
Last active September 9, 2020 06:07
const { id, ...payload_without_id } = payload;
// use case
updateMilestone({ commit, state, getters }, payload) {
const { id, ...payload_without_id } = payload;
const url = `${base_url}api/milestones/${id}/`;
@cyberfly
cyberfly / Form.vue
Last active September 9, 2020 02:03
<template>
<a-form-model ref="ruleForm" :model="milestone_data" :rules="rules">
<a-form-model-item ref="name" label="Name" prop="name">
<a-input v-model="milestone_data.name" />
</a-form-model-item>
<a-form-model-item ref="start_date" label="Start Date" prop="start_date">
<a-date-picker v-model="milestone_data.start_date" />
</a-form-model-item>
userReactionExist(alias) {
let user_id = 1;
let user_reaction = _.find(this.reactions, function (reaction) {
if (reaction.alias == alias) {
if (reaction.user.id == user_id) {
return true;
}
}
_.isEqual(_.sortBy(array1), _.sortBy(array2))
// example
validateArray(field_key) {
let original_array = this.pre_toggle_data[field_key];
let new_array = this.task_data[field_key];
// check contains the same value
mounted() {
// we can set auto focus
this.editor = new Editor({
autoFocus: true
});
// or we can focus programatically