Skip to content

Instantly share code, notes, and snippets.

View mrf345's full-sized avatar

Mohamed Feddad mrf345

  • UAE
View GitHub Profile
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active June 11, 2024 19:48
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@m0rff
m0rff / send_sms.py
Last active November 28, 2022 12:45
Sending a SMS with Python and pyserial via an USB 3G Modem on pfSense/FreeBSD
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
#
# Sending a SMS with Python and pyserial via an USB 3G Modem on pfSense/FreeBSD
# tested with: Huawei Technologies Co., Ltd. E620 USB Modem
# and a Telekom SIM card
import serial
from curses import ascii
import time
@buptxge
buptxge / print_with_win32print.py
Created April 7, 2016 08:38
Print image using win32print and PIL
import win32print
import win32ui
from PIL import Image, ImageWin
PHYSICALWIDTH = 110
PHYSICALHEIGHT = 111
printer_name = win32print.GetDefaultPrinter ()
file_name = "new.jpg"
@subfuzion
subfuzion / github-wiki-how-to.md
Last active June 5, 2024 05:31
GitHub Wiki How-To

How do I clone a GitHub wiki?

Any GitHub wiki can be cloned by appending wiki.git to the repo url, so the clone url for the repo https://myorg/myrepo/ is: git@github.com:myorg/myrepo.wiki.git (for ssh) or https://github.com/my/myrepo.wiki.git (for https).

You make edits, and commit and push your changes, like any normal repo. This wiki repo is distinct from any clone of the project repo (the repo without wiki.get appended).

How do I add images to a wiki page?

@pkazmierczak
pkazmierczak / async-python.py
Last active November 23, 2022 09:49
asyncio example (python3 & python2)
import asyncio
@asyncio.coroutine
def factorial(name, number):
f = 1
for i in range(2, number + 1):
print("Task %s: Compute factorial(%d)..." % (name, i))
yield from asyncio.sleep(1)
f *= i
"""
A simple example pyside app that demonstrates dragging and dropping
of files onto a GUI.
- This app allows dragging and dropping of an image file
that this then displayed in the GUI
- Alternatively an image can be loaded using the button
- This app includes a workaround for using pyside for dragging and dropping
@zmwangx
zmwangx / rule30.py
Last active January 5, 2021 14:26
Stephen Wolfram Rule 30 cellular automaton emulation in python, with the simplest initial state of exactly one filled cell. (UPDATE: I've published a much more efficient and refined package with builtin visualization: https://github.com/zmwangx/rule30)
import sys
MAX_TIME = int(sys.argv[1])
HALF_SIZE = MAX_TIME
indices = range(-HALF_SIZE, HALF_SIZE+1)
# initial condition
cells = {i: '0' for i in indices}
cells[0] = '1'
# padding on both ends
@msukmanowsky
msukmanowsky / image_file_validator.py
Last active November 13, 2017 19:51
An ImageFieldRequired validator for a Flask WTForm.
from flask.ext.wtf import Form
from flask.ext.wtf.file import FileField
import imghdr
class ImageFileRequired(object):
"""
Validates that an uploaded file from a flask_wtf FileField is, in fact an
image. Better than checking the file extension, examines the header of
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active June 11, 2024 11:25
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@bitboxx
bitboxx / gist:5151870
Created March 13, 2013 13:06
Javascript / jQuery: Detect page change using AJAX; auto refresh if the page is updated
// Detect page change / auto refresh
$(document).ready(function() {
var currenthtml;
var latesthtml;
$.get(window.location.href, function(data) {
currenthtml = data;
latesthtml = data;
});