Changing Remote Url Repository Github

Changing Remote Url Repository Github

The git remote set-url command takes two arguments:

  • An existing remote name. For example, origin or upstream are two common choices.
  • A new URL for the remote. For example:
    • If you’re updating to use HTTPS, your URL might look like:
      https://github.com/USERNAME/REPOSITORY.git
      
    • If you’re updating to use SSH, your URL might look like:
      git@github.com:USERNAME/REPOSITORY.git
      

Switching remote URLs from SSH to HTTPS

  1. Open Git Bash.
  2. Change the current working directory to your local project.
  3. List your existing remotes in order to get the name of the remote you want to change.
    git remote -v
    origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
    origin  git@github.com:USERNAME/REPOSITORY.git (push)
    
  4. Change your remote’s URL from SSH to HTTPS with the git remote set-url command.
    git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
    
  5. Verify that the remote URL has changed.
    git remote -v
    # Verify new remote URL
    origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
    origin  https://github.com/USERNAME/REPOSITORY.git (push)
    

The next time you git fetch, git pull, or git push to the remote repository, you’ll be asked for your GitHub username and password.

Switching remote URLs from HTTPS to SSH

  1. Open Git Bash.
  2. Change the current working directory to your local project.
  3. List your existing remotes in order to get the name of the remote you want to change.
    git remote -v
    origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
    origin  https://github.com/USERNAME/REPOSITORY.git (push)
    
  4. Change your remote’s URL from HTTPS to SSH with the git remote set-url command.
    git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
    
  5. Verify that the remote URL has changed.
    git remote -v
    # Verify new remote URL
    origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
    origin  git@github.com:USERNAME/REPOSITORY.git (push)
    

Troubleshooting

You may encounter these errors when trying to changing a remote.

No such remote ‘[name]’

This error means that the remote you tried to change doesn’t exist:

git remote set-url sofake https://github.com/octocat/Spoon-Knife
fatal: No such remote 'sofake'

Check that you’ve correctly typed the remote name.

Further reading

 

docs : https://help.github.com/

Dictionary Raw SQL Queries Django

Python Django

Bagaimana cara membuat dictionary pada raw SQL query django ?

pertama import library django connection

from django.db import connections
cursor = connections['default'].cursor()

 

kedua buat function untuk merubah index menjadi dictionary

def dictfetchall(cursor):
    "Return all rows from a cursor as a dict"
    columns = [col[0] for col in cursor.description]
    return [
        dict(zip(columns, row))
        for row in cursor.fetchall()
        ]

 

ketiga buat function untuk memanggil data dari database

def p_mapping_list(request):
    try:
        cursor.execute("""SELECT id, parent_id FROM test LIMIT 2""")
        all_list = dictfetchall(cursor)
        for p in all_list: 
            print(p.parent_id)
    except:
        cursor.close()
        connections['default'].cursor()

 

link dokumentasihttps://docs.djangoproject.com/en/1.11/topics/db/sql/

good luck …!

 

Php cUrl Http Request

PHP cURL HTTP Request

Apa itu cURL ?, Curl adalah sebuah program yang memungkinan kita memindai data dari atau ke sebuah server tanpa interaksi dari masing-masing user.

Script awal yang akan kita coba adalah me-load sebuah halaman web, memindai kontennya, dan mencetak kembali. dalam SOAP request ada 3 hal yang perlu di pahami

  1. Action
  2. Header
  3. Body

Langsung aja ya :

<?php
$url = “https://xxx.com/index.php?wsdl”;
$header = array(
  ‘Accept: */*’,
  ‘Accept-Language: en-us’,
  ‘Content-Type: text/xml; charset=utf-8’,
  “Cache-Control: no-cache”,
  “Pragma: no-cache”,
  “SOAPAction: ‘urn:WsSearchFlight'”,
);
 
$soap_request = ‘<soapenv:Envelope 	xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:urn=”urn:sj_service”>
  <soapenv:Header/>
  <soapenv:Body>
  	<urn:WsSearchFlight
soapenv:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
  		<param xsi:type=”urn:reqWsSearchFlight” xmlns:urn=”urn:webservice”>
 
  		</param>
  	</urn:WsSearchFlight>
  </soapenv:Body>
</soapenv:Envelope>’;
 
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 1000);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 1000);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
 
if(curl_exec($soap_do) === false) {
  $err = ‘Curl error: ‘ . curl_error($soap_do);
  curl_close($soap_do);
  print $err;
} else {
  $info = curl_exec($soap_do);
  curl_close($soap_do);
  print ‘Operation completed without any errors<br>’;
  print_r($info);
}
 
 
?>

good luck …!

Auto Complete Django

Auto Complete Django

Bagaimana membuat form auto complete pada django ?

Buat sebuah form

<div>
    Hotel Name: <input type="text" id="ean_hotel" name="hotel_name" />
   ID_Ean : <input type="text" id="id_ean" name="id_ean" />
</div>

 

Buat scrip auto complete dengan jquery

<script type="text/javascript">
$(document).ready(function(){
    var ac_config = {
        source:'http://localhost:8002/properties/p-auto',
        headers: {'X-CSRFToken': '{{ csrf_token }}'},
    select: function(event, ui) {
        $('#id_ean').val(ui.item.property_id);
        event.preventDefault();
        $("#ean_hotel").val(ui.item.properties_name); },
        minLength:1
    };
    $("#ean_hotel").autocomplete(ac_config);
});
</script>

 

buat function untuk mengolah data json 

def get_auto_properties(request):
    propertyGet = request.GET.get('term')
    getProperties = Propertiesmodel.objects.filter(name__contains=propertyGet)
 
    lst = []
    for x in getProperties:
        d = {}
        d['ean_hotel_id'] = x.ean_hotel_id
        d['property_id'] = x.property_id
        d['properties_name'] = x.name
        lst.append(d)
 
    response = json.dumps(lst, default=myconverter)
    return HttpResponse(response)
 
def myconverter(o):
    if isinstance(o, datetime):
        return o.__str__()

 

good luck …!

Sample Xpath in Python

sample xpath in python

XPath (XML Path Language) adalah bahasa kueri untuk memilih bagian – bagian (nodes) dari sebuah dokumen XML. XPath juga dapat digunakan untuk menghitung nilai (contoh : string, angka atau boolean) dari isi dari sebuah dokumen XML. XPath distandarisasi oleh World Wide Web Consortium (W3C)

berikut ini contoh penggunaan xpath pada python

buat file xml terlebih dahulu misal kita namakan cancel_response.xml

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
	<SOAP-ENV:Envelope
	xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”
	xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
	xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
	xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/”
	xmlns:tns=”urn:webservice”>
		<SOAP-ENV:Body>
			<ns1:WsCancelPNRResponse xmlns:ns1=”urn:sj_service”>
				<return xsi:type=”tns:respWsCancelPNR”>
					<Username xsi:type=”xsd:string”>xy</Username>
					<BookingCode xsi:type=”xsd:string”>QTGPDF</BookingCode>
					<ErrorCode xsi:type=”xsd:string”>CANCEL0005</ErrorCode>
					<ErrorMessage xsi:type=”xsd:string”>Invalid PNR status.</ErrorMessage>
				</return>
			</ns1:WsCancelPNRResponse>	
		</SOAP-ENV:Body>
	</SOAP-ENV:Envelope>

 

buat file untuk parse XPath misal parse.py

 

import requests
import json
from lxml import etree
from lxml.builder import ElementMaker
from lxml.objectify import fromstring
from io import StringIO, BytesIO
from collections import OrderedDict
 
def process_response():
 
    response = open('cancel_response.xml').read()
    response_namespaces={
        'e' : 'http://schemas.xmlsoap.org/soap/envelope/',
        'ns1':'urn:sj_service'
    }
 
    tree = etree.fromstring(response.encode('utf-8'))
 
    x_response = tree.xpath('//e:Body/ns1:WsCancelPNRResponse/return',namespaces=response_namespaces)
 
    message = x_response[0].xpath('ErrorMessage/text()')[0]
    booking_code = x_response[0].xpath('BookingCode/text()')[0]
 
    response_message = OrderedDict()
    response_message['booking_code'] = booking_code
    response_message['message'] = message
    json_response = json.dumps(response_message)
 
    print(json_response)

 

Good Luck … !