Skip to content

Instantly share code, notes, and snippets.

<?php
$db = @mysql_connect('localhost', 'root', 'password') or die(mysql_error());
mysql_select_db('test', $db) or die(mysql_error());
$qry_qbank = mysql_query("SELECT * FROM at_qa_dump limit 100") or die(mysql_error());
//require('wp-blog-header.php');
while ($row = mysql_fetch_array($qry_qbank)) {
$qno = $row['ID'];
$question_title = $row['Question_Title'];
$question_content = $row['Question_Content'];
<?php
/**
* This file is responsible for displaying question page
* This file can be overridden by creating a anspress directory in active theme folder.
*
public Fragment getVisibleFragment(){
FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
List<Fragment> fragments = fragmentManager.getFragments();
if(fragments != null){
for(Fragment fragment : fragments){
if(fragment != null && fragment.isVisible())
return fragment;
}
}
return null;
private void LoadFragment(String fragmentName, boolean addToBackStack) {
Bundle args = new Bundle();
Fragment fragment = null;
if(fragmentName == "HomeFragment") {
fragment = new HomeFragment();
args.putBoolean("hasValues", false);
} else if(fragmentName == "SettingsFragment") {
fragment = new SettingsFragment();
args.putBoolean("hasValues", false);
} else if(fragmentName == "HelpFragment") {
<?php
function AddQuestionToAnsPress($question_title, $question_content, $answer_content, $subject_id, $exam_id) {
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/wp-blog-header.php";
require($path);
$question_title = strip_tags($question_title);
$category_id = $subject_id;
$category = array($category_id);
$tag_subject_id = $subject_id;
$tags = array(25, $tag_subject_id);
Atuls-MacBook-Pro:~ Atul$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
This file has been truncated, but you can view the full file.
Last login: Tue Dec 6 02:53:58 on ttys000
Atuls-MacBook-Pro:~ Atul$ ./dezoom.sh 189 105 "http://122.160.116.48/DSStore/code/tileHandler.ashx?Id=19110&imageId=-1&tierIndex=0&tileLevel=1&tilePositionX=%X&tilePositionY=%Y&contentType=image/jpeg&isCropped=1"
Downloading... 100%
Tiles added.
convert: Empty input file `/var/folders/hw/jgsyw4_j28v5r129z_c5ryc00000gn/T/tmp.JOeHUMo7/tile95_1.jpg' @ error/jpeg.c/JPEGErrorHandler/322.
convert: no images defined `miff:-' @ error/convert.c/ConvertImageCommand/3258.
convert: Empty input file `/var/folders/hw/jgsyw4_j28v5r129z_c5ryc00000gn/T/tmp.JOeHUMo7/tile96_1.jpg' @ error/jpeg.c/JPEGErrorHandler/322.
convert: no images defined `miff:-' @ error/convert.c/ConvertImageCommand/3258.
convert: Empty input file `/var/folders/hw/jgsyw4_j28v5r129z_c5ryc00000gn/T/tmp.JOeHUMo7/tile97_1.jpg' @ error/jpeg.c/JPEGErrorHandler/322.
convert: no images defined `miff:-' @ error/convert.c/ConvertImageCommand/3258.
@atultiwari
atultiwari / Question.php
Created November 23, 2017 02:58
Add question programmatically in Anspress
$question_array = array(
'post_title' => $question_title,
'post_author' => $user_id_for_question,
'post_content' => $question_content,
'post_type' => 'question',
'post_status' => 'publish',
'comment_status' => 'open'
);
$question_post_id = wp_insert_post($question_array);
if ($question_post_id) {
<?php
get_header();
?>
<div class="container">
<div class="row">
<div id="content" class="main-content-inner col-sm-12<?php echo ' col-md-12' ?>">
<article id="template" class="template page type-page status-publish hentry">
<header>
<h1 class="page-title" align="center">Page Title
<?php
$form = anspress()->get_form( 'answer' );
$values = array(
'post_content' => $mcq_answer,
'post_type' => 'answer',
'post_status' => 'publish',
'post_parent' => $anspress_question_id,
'comment_status' => 'open',
);