Skip to content

Instantly share code, notes, and snippets.

View sgcrafted's full-sized avatar
🤗
less is more

shivangi sgcrafted

🤗
less is more
View GitHub Profile
@sgcrafted
sgcrafted / uncommit.md
Last active April 22, 2017 09:24
This file contains method to uncommit files and message and simply uncommit a message

to uncommit all the stuff: both the message and added files:
git reset HEAD~

in this case you would have to add files and add message before making commit.(changed and added files(staged) are unstaged).

if just just want to edit message of the commit then use soft HEAD:
git reset --soft HEAD~

to reset to a particlar commit :
git reset --hard 4a155e5

@sgcrafted
sgcrafted / bash_profile
Created April 20, 2017 00:14
to make ~/bashrc file run automatically on each terminal start
open .bash_profile file (vim ~/.bash_profile)
add this ->
[[ -s ~/.bashrc ]] && source ~/.bashrc
@sgcrafted
sgcrafted / git1.md
Last active February 27, 2017 15:48
when u commit and then realize that yo have not pulled from remote.Follow these steps to avoid adding an extra merge commit to your branch and keep the commits clean.

Say the branch in which you were working was : master

git add -A
git commit -m "added few changes"
commit hash = 5e108f2

you added your work and then committed it. But then realised you forgot to pull.Now:
git checkout -b newtry master
// git checkout newtry -->optional : try without this

@sgcrafted
sgcrafted / php_mysql.php
Created June 11, 2016 20:50
this code setsup PDO connection of php with mysql. for running it use command :
<?php
$servername='localhost';
$username='root';
$password='password';
try {
$conn = new PDO("mysql:host=$servername;dbname=testdb1", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
import socket
import sys
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind the socket to the port
server_address = ('localhost', 10000)
print >>sys.stderr, 'starting up on %s port %s' % server_address
this file contains python socket programing and many other codes.
import java.awt.*;
import javax.swing.*;
import javax.sound.midi.*;
import java.util.*;
import java.awt.event.*;
public class BeatBox2
{
JPanel mainPanel;
ArrayList<JCheckBox> checkboxList;