Skip to content

Instantly share code, notes, and snippets.

@Fanna1119
Fanna1119 / Django_ajax_file_upload.py
Last active May 26, 2021 19:47
Django Ajax File Upload with image compression
//HtML
<form>
{% csrf_token %}
<input type="file" name="pic" accept="image/*" id="image">
<input type="submit" id="send">
</form>
//JS
@Fanna1119
Fanna1119 / js
Created May 17, 2018 18:13
img compress.js
$('form').submit(function (e) {
e.preventDefault();
var formData = new FormData($(this));
var image_file = $("#file_select")[0].files[0];
if (!image_file) {
return;
@Fanna1119
Fanna1119 / faster_requests.py
Created June 20, 2018 10:06
Faster python3 requests using built in http.client
import http.client
import ujson
def json_dump(data):
return ujson.dumps(ujson.loads(data), indent=4, escape_forward_slashes=False)
def search_web(host, url):
connection = http.client.HTTPConnection(host=host, timeout=10)
connection.request(method="GET", url=url)
@Fanna1119
Fanna1119 / scrape.py
Created October 6, 2018 08:06
scrape html without bloatiful soup
import http.client
from lxml import html
conn = http.client.HTTPSConnection("www.thesaurus.com")
conn.request("GET", "/browse/honesty")
r1 = conn.getresponse()
data1 = r1.read()
# print(data1)
# raw html
@Fanna1119
Fanna1119 / vue2.vue
Created July 22, 2020 12:47
vue2 -> vue3 comparison - VUEJS
<template>
<div>
<h1 class="timer">{{toMin}}</h1>
</div>
</template>
<script>
export default {
data() {
return {
@Fanna1119
Fanna1119 / App.vue
Created November 12, 2020 09:40
vue 3 multiple v-models
<template>
<settings
v-model:day="store.day"
v-model:month="store.month"
v-model:year="store.year"
/>
<timeleft />
</template>
<script>
@Fanna1119
Fanna1119 / App.vue
Last active November 14, 2020 09:16
v-models, emits, vue3
<template>
<datpicker
v-model:day="store.day"
v-model:month="store.month"
v-model:year="store.year"
@birthDate="checkit"
/>
</template>
<script>
@Fanna1119
Fanna1119 / progressbar.vue
Last active March 9, 2021 06:57
simple vue3 progressbar
<template>
<div class="progress" :data-label="percent + '%'">
<span
class="value"
:style="{ width: percent + '%', backgroundColor: getColor }"
></span>
</div>
<input type="range" min="0" max="100" v-model="percent" />
</template>
<template>
<main class="hero-full">
<div class="text-center text-6xl font-bold text-white hero-body">
<router-view />
<Footer />
</div>
</main>
</template>
import add from "lodash-es/add";
import after from "lodash-es/after";
import ary from "lodash-es/ary";
import assign from "lodash-es/assign";
import assignIn from "lodash-es/assignIn";
import assignInWith from "lodash-es/assignInWith";
import assignWith from "lodash-es/assignWith";
import at from "lodash-es/at";
import attempt from "lodash-es/attempt";
import before from "lodash-es/before";